From c32398fe3eec0436974787683c3c93a392cb98db Mon Sep 17 00:00:00 2001 From: DrTimothyAldenDavis Date: Thu, 29 Aug 2024 20:08:06 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20GraphBLA?= =?UTF-8?q?S/LAGraph@1bd0c3df793fab6370642ec37bd255be16c4c284=20?= =?UTF-8?q?=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- amber.png | Bin 0 -> 141 bytes emerald.png | Bin 0 -> 141 bytes .../LAGraph_AllKCore.c.func-sort-c.html | 76 ++ .../algorithm/LAGraph_AllKCore.c.func.html | 76 ++ .../algorithm/LAGraph_AllKCore.c.gcov.html | 226 ++++ .../LAGraph_AllKTruss.c.func-sort-c.html | 76 ++ .../algorithm/LAGraph_AllKTruss.c.func.html | 76 ++ .../algorithm/LAGraph_AllKTruss.c.gcov.html | 256 ++++ .../LAGraph_BF_basic.c.func-sort-c.html | 76 ++ .../algorithm/LAGraph_BF_basic.c.func.html | 76 ++ .../algorithm/LAGraph_BF_basic.c.gcov.html | 205 +++ .../LAGraph_BF_basic_mxv.c.func-sort-c.html | 76 ++ .../LAGraph_BF_basic_mxv.c.func.html | 76 ++ .../LAGraph_BF_basic_mxv.c.gcov.html | 208 +++ ...Graph_BF_basic_pushpull.c.func-sort-c.html | 76 ++ .../LAGraph_BF_basic_pushpull.c.func.html | 76 ++ .../LAGraph_BF_basic_pushpull.c.gcov.html | 315 +++++ .../LAGraph_BF_full.c.func-sort-c.html | 88 ++ .../algorithm/LAGraph_BF_full.c.func.html | 88 ++ .../algorithm/LAGraph_BF_full.c.gcov.html | 386 ++++++ .../LAGraph_BF_full1.c.func-sort-c.html | 92 ++ .../algorithm/LAGraph_BF_full1.c.func.html | 92 ++ .../algorithm/LAGraph_BF_full1.c.gcov.html | 445 +++++++ .../LAGraph_BF_full1a.c.func-sort-c.html | 88 ++ .../algorithm/LAGraph_BF_full1a.c.func.html | 88 ++ .../algorithm/LAGraph_BF_full1a.c.gcov.html | 467 +++++++ .../LAGraph_BF_full2.c.func-sort-c.html | 88 ++ .../algorithm/LAGraph_BF_full2.c.func.html | 88 ++ .../algorithm/LAGraph_BF_full2.c.gcov.html | 425 +++++++ .../LAGraph_BF_full_mxv.c.func-sort-c.html | 88 ++ .../algorithm/LAGraph_BF_full_mxv.c.func.html | 88 ++ .../algorithm/LAGraph_BF_full_mxv.c.gcov.html | 414 ++++++ .../LAGraph_BF_pure_c.c.func-sort-c.html | 76 ++ .../algorithm/LAGraph_BF_pure_c.c.func.html | 76 ++ .../algorithm/LAGraph_BF_pure_c.c.gcov.html | 212 ++++ ...AGraph_BF_pure_c_double.c.func-sort-c.html | 76 ++ .../LAGraph_BF_pure_c_double.c.func.html | 76 ++ .../LAGraph_BF_pure_c_double.c.gcov.html | 214 ++++ ...h_FastGraphletTransform.c.func-sort-c.html | 80 ++ .../LAGraph_FastGraphletTransform.c.func.html | 80 ++ .../LAGraph_FastGraphletTransform.c.gcov.html | 677 ++++++++++ .../LAGraph_HelloWorld.c.func-sort-c.html | 76 ++ .../algorithm/LAGraph_HelloWorld.c.func.html | 76 ++ .../algorithm/LAGraph_HelloWorld.c.gcov.html | 175 +++ .../LAGraph_KCore.c.func-sort-c.html | 76 ++ .../algorithm/LAGraph_KCore.c.func.html | 76 ++ .../algorithm/LAGraph_KCore.c.gcov.html | 213 ++++ .../LAGraph_KCoreDecompose.c.func-sort-c.html | 76 ++ .../LAGraph_KCoreDecompose.c.func.html | 76 ++ .../LAGraph_KCoreDecompose.c.gcov.html | 192 +++ .../LAGraph_KTruss.c.func-sort-c.html | 76 ++ .../algorithm/LAGraph_KTruss.c.func.html | 76 ++ .../algorithm/LAGraph_KTruss.c.gcov.html | 190 +++ ...h_MaximalIndependentSet.c.func-sort-c.html | 76 ++ .../LAGraph_MaximalIndependentSet.c.func.html | 76 ++ .../LAGraph_MaximalIndependentSet.c.gcov.html | 391 ++++++ ...AGraph_SquareClustering.c.func-sort-c.html | 76 ++ .../LAGraph_SquareClustering.c.func.html | 76 ++ .../LAGraph_SquareClustering.c.gcov.html | 313 +++++ ...rtexCentrality_Triangle.c.func-sort-c.html | 76 ++ ...raph_VertexCentrality_Triangle.c.func.html | 76 ++ ...raph_VertexCentrality_Triangle.c.gcov.html | 394 ++++++ .../LAGraph_cc_lacc.c.func-sort-c.html | 80 ++ .../algorithm/LAGraph_cc_lacc.c.func.html | 80 ++ .../algorithm/LAGraph_cc_lacc.c.gcov.html | 306 +++++ .../algorithm/LAGraph_cdlp.c.func-sort-c.html | 76 ++ .../algorithm/LAGraph_cdlp.c.func.html | 76 ++ .../algorithm/LAGraph_cdlp.c.gcov.html | 435 +++++++ .../algorithm/LAGraph_dnn.c.func-sort-c.html | 76 ++ .../algorithm/LAGraph_dnn.c.func.html | 76 ++ .../algorithm/LAGraph_dnn.c.gcov.html | 191 +++ .../algorithm/LAGraph_lcc.c.func-sort-c.html | 84 ++ .../algorithm/LAGraph_lcc.c.func.html | 84 ++ .../algorithm/LAGraph_lcc.c.gcov.html | 374 ++++++ .../algorithm/LAGraph_msf.c.func-sort-c.html | 100 ++ .../algorithm/LAGraph_msf.c.func.html | 100 ++ .../algorithm/LAGraph_msf.c.gcov.html | 354 ++++++ .../algorithm/LAGraph_scc.c.func-sort-c.html | 88 ++ .../algorithm/LAGraph_scc.c.func.html | 88 ++ .../algorithm/LAGraph_scc.c.gcov.html | 321 +++++ .../LG_CC_FastSV5.c.func-sort-c.html | 92 ++ .../algorithm/LG_CC_FastSV5.c.func.html | 92 ++ .../algorithm/LG_CC_FastSV5.c.gcov.html | 864 +++++++++++++ experimental/algorithm/index-sort-f.html | 353 ++++++ experimental/algorithm/index-sort-l.html | 353 ++++++ experimental/algorithm/index.html | 353 ++++++ .../test/LG_check_kcore.c.func-sort-c.html | 76 ++ experimental/test/LG_check_kcore.c.func.html | 76 ++ experimental/test/LG_check_kcore.c.gcov.html | 258 ++++ ...LG_check_kcoredecompose.c.func-sort-c.html | 76 ++ .../test/LG_check_kcoredecompose.c.func.html | 76 ++ .../test/LG_check_kcoredecompose.c.gcov.html | 192 +++ .../test/LG_check_ktruss.c.func-sort-c.html | 76 ++ experimental/test/LG_check_ktruss.c.func.html | 76 ++ experimental/test/LG_check_ktruss.c.gcov.html | 256 ++++ .../test/LG_check_mis.c.func-sort-c.html | 76 ++ experimental/test/LG_check_mis.c.func.html | 76 ++ experimental/test/LG_check_mis.c.gcov.html | 203 +++ experimental/test/index-sort-f.html | 323 +++++ experimental/test/index-sort-l.html | 323 +++++ experimental/test/index.html | 323 +++++ .../test/test_AllKCore.c.func-sort-c.html | 80 ++ experimental/test/test_AllKCore.c.func.html | 80 ++ experimental/test/test_AllKCore.c.gcov.html | 262 ++++ .../test/test_AllKtruss.c.func-sort-c.html | 80 ++ experimental/test/test_AllKtruss.c.func.html | 80 ++ experimental/test/test_AllKtruss.c.gcov.html | 338 +++++ experimental/test/test_BF.c.func-sort-c.html | 84 ++ experimental/test/test_BF.c.func.html | 84 ++ experimental/test/test_BF.c.gcov.html | 592 +++++++++ ...t_FastGraphletTransform.c.func-sort-c.html | 76 ++ .../test_FastGraphletTransform.c.func.html | 76 ++ .../test_FastGraphletTransform.c.gcov.html | 251 ++++ .../test/test_HelloWorld.c.func-sort-c.html | 76 ++ experimental/test/test_HelloWorld.c.func.html | 76 ++ experimental/test/test_HelloWorld.c.gcov.html | 161 +++ .../test/test_KCore.c.func-sort-c.html | 80 ++ experimental/test/test_KCore.c.func.html | 80 ++ experimental/test/test_KCore.c.gcov.html | 249 ++++ .../test_KCoreDecompose.c.func-sort-c.html | 80 ++ .../test/test_KCoreDecompose.c.func.html | 80 ++ .../test/test_KCoreDecompose.c.gcov.html | 267 ++++ .../test/test_KTruss.c.func-sort-c.html | 80 ++ experimental/test/test_KTruss.c.func.html | 80 ++ experimental/test/test_KTruss.c.gcov.html | 280 ++++ ...t_MaximalIndependentSet.c.func-sort-c.html | 84 ++ .../test_MaximalIndependentSet.c.func.html | 84 ++ .../test_MaximalIndependentSet.c.gcov.html | 327 +++++ .../test/test_Random.c.func-sort-c.html | 76 ++ experimental/test/test_Random.c.func.html | 76 ++ experimental/test/test_Random.c.gcov.html | 162 +++ .../test_Random_Matrix.c.func-sort-c.html | 76 ++ .../test/test_Random_Matrix.c.func.html | 76 ++ .../test/test_Random_Matrix.c.gcov.html | 205 +++ .../test/test_SSaveSet.c.func-sort-c.html | 76 ++ experimental/test/test_SSaveSet.c.func.html | 76 ++ experimental/test/test_SSaveSet.c.gcov.html | 244 ++++ .../test/test_SWrite.c.func-sort-c.html | 80 ++ experimental/test/test_SWrite.c.func.html | 80 ++ experimental/test/test_SWrite.c.gcov.html | 467 +++++++ .../test_SquareClustering.c.func-sort-c.html | 80 ++ .../test/test_SquareClustering.c.func.html | 80 ++ .../test/test_SquareClustering.c.gcov.html | 183 +++ ...test_TriangleCentrality.c.func-sort-c.html | 80 ++ .../test/test_TriangleCentrality.c.func.html | 80 ++ .../test/test_TriangleCentrality.c.gcov.html | 265 ++++ .../test/test_cdlp.c.func-sort-c.html | 80 ++ experimental/test/test_cdlp.c.func.html | 80 ++ experimental/test/test_cdlp.c.gcov.html | 321 +++++ experimental/test/test_dnn.c.func-sort-c.html | 84 ++ experimental/test/test_dnn.c.func.html | 84 ++ experimental/test/test_dnn.c.gcov.html | 278 ++++ experimental/test/test_lcc.c.func-sort-c.html | 80 ++ experimental/test/test_lcc.c.func.html | 80 ++ experimental/test/test_lcc.c.gcov.html | 326 +++++ experimental/test/test_msf.c.func-sort-c.html | 80 ++ experimental/test/test_msf.c.func.html | 80 ++ experimental/test/test_msf.c.gcov.html | 238 ++++ experimental/test/test_scc.c.func-sort-c.html | 80 ++ experimental/test/test_scc.c.func.html | 80 ++ experimental/test/test_scc.c.gcov.html | 271 ++++ .../utility/LAGraph_Random.c.func-sort-c.html | 92 ++ .../utility/LAGraph_Random.c.func.html | 92 ++ .../utility/LAGraph_Random.c.gcov.html | 252 ++++ .../LAGraph_Random_Matrix.c.func-sort-c.html | 80 ++ .../utility/LAGraph_Random_Matrix.c.func.html | 80 ++ .../utility/LAGraph_Random_Matrix.c.gcov.html | 515 ++++++++ .../LAGraph_SFreeContents.c.func-sort-c.html | 76 ++ .../utility/LAGraph_SFreeContents.c.func.html | 76 ++ .../utility/LAGraph_SFreeContents.c.gcov.html | 116 ++ .../LAGraph_SFreeSet.c.func-sort-c.html | 76 ++ .../utility/LAGraph_SFreeSet.c.func.html | 76 ++ .../utility/LAGraph_SFreeSet.c.gcov.html | 116 ++ .../LAGraph_SLoadSet.c.func-sort-c.html | 76 ++ .../utility/LAGraph_SLoadSet.c.func.html | 76 ++ .../utility/LAGraph_SLoadSet.c.gcov.html | 248 ++++ .../utility/LAGraph_SRead.c.func-sort-c.html | 80 ++ .../utility/LAGraph_SRead.c.func.html | 80 ++ .../utility/LAGraph_SRead.c.gcov.html | 450 +++++++ .../LAGraph_SSaveSet.c.func-sort-c.html | 76 ++ .../utility/LAGraph_SSaveSet.c.func.html | 76 ++ .../utility/LAGraph_SSaveSet.c.gcov.html | 222 ++++ .../utility/LAGraph_SWrite.c.func-sort-c.html | 88 ++ .../utility/LAGraph_SWrite.c.func.html | 88 ++ .../utility/LAGraph_SWrite.c.gcov.html | 256 ++++ experimental/utility/index-sort-f.html | 163 +++ experimental/utility/index-sort-l.html | 163 +++ experimental/utility/index.html | 163 +++ gcov.css | 519 ++++++++ glass.png | Bin 0 -> 167 bytes index-sort-f.html | 143 +++ index-sort-l.html | 143 +++ index.html | 143 +++ ruby.png | Bin 0 -> 141 bytes snow.png | Bin 0 -> 141 bytes .../LAGr_Betweenness.c.func-sort-c.html | 76 ++ src/algorithm/LAGr_Betweenness.c.func.html | 76 ++ src/algorithm/LAGr_Betweenness.c.gcov.html | 396 ++++++ ...LAGr_BreadthFirstSearch.c.func-sort-c.html | 76 ++ .../LAGr_BreadthFirstSearch.c.func.html | 76 ++ .../LAGr_BreadthFirstSearch.c.gcov.html | 121 ++ ...AGr_ConnectedComponents.c.func-sort-c.html | 76 ++ .../LAGr_ConnectedComponents.c.func.html | 76 ++ .../LAGr_ConnectedComponents.c.gcov.html | 117 ++ .../LAGr_PageRank.c.func-sort-c.html | 76 ++ src/algorithm/LAGr_PageRank.c.func.html | 76 ++ src/algorithm/LAGr_PageRank.c.gcov.html | 261 ++++ .../LAGr_PageRankGAP.c.func-sort-c.html | 76 ++ src/algorithm/LAGr_PageRankGAP.c.func.html | 76 ++ src/algorithm/LAGr_PageRankGAP.c.gcov.html | 228 ++++ ...ingleSourceShortestPath.c.func-sort-c.html | 76 ++ .../LAGr_SingleSourceShortestPath.c.func.html | 76 ++ .../LAGr_SingleSourceShortestPath.c.gcov.html | 498 ++++++++ .../LAGr_TriangleCount.c.func-sort-c.html | 80 ++ src/algorithm/LAGr_TriangleCount.c.func.html | 80 ++ src/algorithm/LAGr_TriangleCount.c.gcov.html | 442 +++++++ .../LAGraph_TriangleCount.c.func-sort-c.html | 76 ++ .../LAGraph_TriangleCount.c.func.html | 76 ++ .../LAGraph_TriangleCount.c.gcov.html | 122 ++ ...readthFirstSearch_SSGrB.c.func-sort-c.html | 76 ++ .../LG_BreadthFirstSearch_SSGrB.c.func.html | 76 ++ .../LG_BreadthFirstSearch_SSGrB.c.gcov.html | 374 ++++++ ...adthFirstSearch_vanilla.c.func-sort-c.html | 76 ++ .../LG_BreadthFirstSearch_vanilla.c.func.html | 76 ++ .../LG_BreadthFirstSearch_vanilla.c.gcov.html | 241 ++++ .../LG_CC_Boruvka.c.func-sort-c.html | 84 ++ src/algorithm/LG_CC_Boruvka.c.func.html | 84 ++ src/algorithm/LG_CC_Boruvka.c.gcov.html | 356 ++++++ .../LG_CC_FastSV6.c.func-sort-c.html | 80 ++ src/algorithm/LG_CC_FastSV6.c.func.html | 80 ++ src/algorithm/LG_CC_FastSV6.c.gcov.html | 747 +++++++++++ src/algorithm/index-sort-f.html | 203 +++ src/algorithm/index-sort-l.html | 203 +++ src/algorithm/index.html | 203 +++ src/test/LG_brutal_malloc.c.func-sort-c.html | 88 ++ src/test/LG_brutal_malloc.c.func.html | 88 ++ src/test/LG_brutal_malloc.c.gcov.html | 240 ++++ src/test/LG_brutal_setup.c.func-sort-c.html | 76 ++ src/test/LG_brutal_setup.c.func.html | 76 ++ src/test/LG_brutal_setup.c.gcov.html | 112 ++ .../LG_brutal_teardown.c.func-sort-c.html | 76 ++ src/test/LG_brutal_teardown.c.func.html | 76 ++ src/test/LG_brutal_teardown.c.gcov.html | 103 ++ src/test/LG_check_bfs.c.func-sort-c.html | 76 ++ src/test/LG_check_bfs.c.func.html | 76 ++ src/test/LG_check_bfs.c.gcov.html | 321 +++++ src/test/LG_check_cc.c.func-sort-c.html | 76 ++ src/test/LG_check_cc.c.func.html | 76 ++ src/test/LG_check_cc.c.gcov.html | 304 +++++ src/test/LG_check_export.c.func-sort-c.html | 76 ++ src/test/LG_check_export.c.func.html | 76 ++ src/test/LG_check_export.c.gcov.html | 223 ++++ src/test/LG_check_sssp.c.func-sort-c.html | 76 ++ src/test/LG_check_sssp.c.func.html | 76 ++ src/test/LG_check_sssp.c.gcov.html | 460 +++++++ src/test/LG_check_tri.c.func-sort-c.html | 76 ++ src/test/LG_check_tri.c.func.html | 76 ++ src/test/LG_check_tri.c.gcov.html | 215 ++++ src/test/LG_check_vector.c.func-sort-c.html | 76 ++ src/test/LG_check_vector.c.func.html | 76 ++ src/test/LG_check_vector.c.gcov.html | 124 ++ src/test/LG_heap.h.func-sort-c.html | 92 ++ src/test/LG_heap.h.func.html | 92 ++ src/test/LG_heap.h.gcov.html | 505 ++++++++ src/test/index-sort-f.html | 543 ++++++++ src/test/index-sort-l.html | 543 ++++++++ src/test/index.html | 543 ++++++++ src/test/test_Betweenness.c.func-sort-c.html | 84 ++ src/test/test_Betweenness.c.func.html | 84 ++ src/test/test_Betweenness.c.gcov.html | 401 ++++++ ...test_BreadthFirstSearch.c.func-sort-c.html | 120 ++ src/test/test_BreadthFirstSearch.c.func.html | 120 ++ src/test/test_BreadthFirstSearch.c.gcov.html | 753 +++++++++++ src/test/test_Cached_AT.c.func-sort-c.html | 88 ++ src/test/test_Cached_AT.c.func.html | 88 ++ src/test/test_Cached_AT.c.gcov.html | 290 +++++ .../test_Cached_Degree.c.func-sort-c.html | 92 ++ src/test/test_Cached_Degree.c.func.html | 92 ++ src/test/test_Cached_Degree.c.gcov.html | 445 +++++++ src/test/test_Cached_NDiag.c.func-sort-c.html | 88 ++ src/test/test_Cached_NDiag.c.func.html | 88 ++ src/test/test_Cached_NDiag.c.gcov.html | 299 +++++ ...ched_SymmetricStructure.c.func-sort-c.html | 88 ++ ...test_Cached_SymmetricStructure.c.func.html | 88 ++ ...test_Cached_SymmetricStructure.c.gcov.html | 365 ++++++ src/test/test_CheckGraph.c.func-sort-c.html | 92 ++ src/test/test_CheckGraph.c.func.html | 92 ++ src/test/test_CheckGraph.c.gcov.html | 377 ++++++ ...est_ConnectedComponents.c.func-sort-c.html | 88 ++ src/test/test_ConnectedComponents.c.func.html | 88 ++ src/test/test_ConnectedComponents.c.gcov.html | 351 +++++ src/test/test_DeleteCached.c.func-sort-c.html | 88 ++ src/test/test_DeleteCached.c.func.html | 88 ++ src/test/test_DeleteCached.c.gcov.html | 277 ++++ src/test/test_DisplayGraph.c.func-sort-c.html | 96 ++ src/test/test_DisplayGraph.c.func.html | 96 ++ src/test/test_DisplayGraph.c.gcov.html | 378 ++++++ src/test/test_Init.c.func-sort-c.html | 76 ++ src/test/test_Init.c.func.html | 76 ++ src/test/test_Init.c.gcov.html | 172 +++ src/test/test_Init_errors.c.func-sort-c.html | 76 ++ src/test/test_Init_errors.c.func.html | 76 ++ src/test/test_Init_errors.c.gcov.html | 138 ++ src/test/test_IsEqual.c.func-sort-c.html | 96 ++ src/test/test_IsEqual.c.func.html | 96 ++ src/test/test_IsEqual.c.gcov.html | 528 ++++++++ src/test/test_KindName.c.func-sort-c.html | 88 ++ src/test/test_KindName.c.func.html | 88 ++ src/test/test_KindName.c.gcov.html | 174 +++ src/test/test_MMRead.c.func-sort-c.html | 112 ++ src/test/test_MMRead.c.func.html | 112 ++ src/test/test_MMRead.c.gcov.html | 859 +++++++++++++ src/test/test_Malloc.c.func-sort-c.html | 76 ++ src/test/test_Malloc.c.func.html | 76 ++ src/test/test_Malloc.c.gcov.html | 197 +++ .../test_Matrix_Structure.c.func-sort-c.html | 92 ++ src/test/test_Matrix_Structure.c.func.html | 92 ++ src/test/test_Matrix_Structure.c.gcov.html | 262 ++++ .../test_Multiply_size_t.c.func-sort-c.html | 76 ++ src/test/test_Multiply_size_t.c.func.html | 76 ++ src/test/test_Multiply_size_t.c.gcov.html | 129 ++ src/test/test_New.c.func-sort-c.html | 92 ++ src/test/test_New.c.func.html | 92 ++ src/test/test_New.c.gcov.html | 265 ++++ src/test/test_NumThreads.c.func-sort-c.html | 76 ++ src/test/test_NumThreads.c.func.html | 76 ++ src/test/test_NumThreads.c.gcov.html | 153 +++ src/test/test_PageRank.c.func-sort-c.html | 80 ++ src/test/test_PageRank.c.func.html | 80 ++ src/test/test_PageRank.c.gcov.html | 415 ++++++ src/test/test_SampleDegree.c.func-sort-c.html | 92 ++ src/test/test_SampleDegree.c.func.html | 92 ++ src/test/test_SampleDegree.c.gcov.html | 334 +++++ ...ingleSourceShortestPath.c.func-sort-c.html | 88 ++ .../test_SingleSourceShortestPath.c.func.html | 88 ++ .../test_SingleSourceShortestPath.c.gcov.html | 532 ++++++++ src/test/test_Sort.c.func-sort-c.html | 96 ++ src/test/test_Sort.c.func.html | 96 ++ src/test/test_Sort.c.gcov.html | 430 +++++++ src/test/test_SortByDegree.c.func-sort-c.html | 92 ++ src/test/test_SortByDegree.c.func.html | 92 ++ src/test/test_SortByDegree.c.gcov.html | 510 ++++++++ .../test_TriangleCount.c.func-sort-c.html | 120 ++ src/test/test_TriangleCount.c.func.html | 120 ++ src/test/test_TriangleCount.c.gcov.html | 566 +++++++++ src/test/test_Type.c.func-sort-c.html | 80 ++ src/test/test_Type.c.func.html | 80 ++ src/test/test_Type.c.gcov.html | 263 ++++ src/test/test_Vector_Print.c.func-sort-c.html | 80 ++ src/test/test_Vector_Print.c.func.html | 80 ++ src/test/test_Vector_Print.c.gcov.html | 294 +++++ .../test_Vector_Structure.c.func-sort-c.html | 92 ++ src/test/test_Vector_Structure.c.func.html | 92 ++ src/test/test_Vector_Structure.c.gcov.html | 263 ++++ .../test_WallClockTime.c.func-sort-c.html | 76 ++ src/test/test_WallClockTime.c.func.html | 76 ++ src/test/test_WallClockTime.c.gcov.html | 144 +++ src/test/test_Xinit.c.func-sort-c.html | 80 ++ src/test/test_Xinit.c.func.html | 80 ++ src/test/test_Xinit.c.gcov.html | 262 ++++ src/test/test_acutest.c.func-sort-c.html | 76 ++ src/test/test_acutest.c.func.html | 76 ++ src/test/test_acutest.c.gcov.html | 124 ++ src/test/test_export.c.func-sort-c.html | 80 ++ src/test/test_export.c.func.html | 80 ++ src/test/test_export.c.gcov.html | 295 +++++ src/test/test_fopen.c.func-sort-c.html | 80 ++ src/test/test_fopen.c.func.html | 80 ++ src/test/test_fopen.c.gcov.html | 128 ++ src/test/test_minmax.c.func-sort-c.html | 96 ++ src/test/test_minmax.c.func.html | 96 ++ src/test/test_minmax.c.gcov.html | 539 ++++++++ src/test/test_vector.c.func-sort-c.html | 80 ++ src/test/test_vector.c.func.html | 80 ++ src/test/test_vector.c.gcov.html | 187 +++ src/utility/LAGr_Init.c.func-sort-c.html | 84 ++ src/utility/LAGr_Init.c.func.html | 84 ++ src/utility/LAGr_Init.c.gcov.html | 407 ++++++ .../LAGr_SampleDegree.c.func-sort-c.html | 76 ++ src/utility/LAGr_SampleDegree.c.func.html | 76 ++ src/utility/LAGr_SampleDegree.c.gcov.html | 188 +++ .../LAGr_SortByDegree.c.func-sort-c.html | 76 ++ src/utility/LAGr_SortByDegree.c.func.html | 76 ++ src/utility/LAGr_SortByDegree.c.gcov.html | 243 ++++ .../LAGraph_Cached_AT.c.func-sort-c.html | 76 ++ src/utility/LAGraph_Cached_AT.c.func.html | 76 ++ src/utility/LAGraph_Cached_AT.c.gcov.html | 142 +++ .../LAGraph_Cached_EMax.c.func-sort-c.html | 76 ++ src/utility/LAGraph_Cached_EMax.c.func.html | 76 ++ src/utility/LAGraph_Cached_EMax.c.gcov.html | 156 +++ .../LAGraph_Cached_EMin.c.func-sort-c.html | 76 ++ src/utility/LAGraph_Cached_EMin.c.func.html | 76 ++ src/utility/LAGraph_Cached_EMin.c.gcov.html | 156 +++ ...LAGraph_Cached_InDegree.c.func-sort-c.html | 76 ++ .../LAGraph_Cached_InDegree.c.func.html | 76 ++ .../LAGraph_Cached_InDegree.c.gcov.html | 181 +++ ...ed_IsSymmetricStructure.c.func-sort-c.html | 76 ++ ...ph_Cached_IsSymmetricStructure.c.func.html | 76 ++ ...ph_Cached_IsSymmetricStructure.c.gcov.html | 179 +++ ...Graph_Cached_NSelfEdges.c.func-sort-c.html | 76 ++ .../LAGraph_Cached_NSelfEdges.c.func.html | 76 ++ .../LAGraph_Cached_NSelfEdges.c.gcov.html | 121 ++ ...AGraph_Cached_OutDegree.c.func-sort-c.html | 76 ++ .../LAGraph_Cached_OutDegree.c.func.html | 76 ++ .../LAGraph_Cached_OutDegree.c.gcov.html | 158 +++ src/utility/LAGraph_Calloc.c.func-sort-c.html | 76 ++ src/utility/LAGraph_Calloc.c.func.html | 76 ++ src/utility/LAGraph_Calloc.c.gcov.html | 136 ++ .../LAGraph_CheckGraph.c.func-sort-c.html | 76 ++ src/utility/LAGraph_CheckGraph.c.func.html | 76 ++ src/utility/LAGraph_CheckGraph.c.gcov.html | 193 +++ src/utility/LAGraph_Delete.c.func-sort-c.html | 76 ++ src/utility/LAGraph_Delete.c.func.html | 76 ++ src/utility/LAGraph_Delete.c.gcov.html | 132 ++ .../LAGraph_DeleteCached.c.func-sort-c.html | 76 ++ src/utility/LAGraph_DeleteCached.c.func.html | 76 ++ src/utility/LAGraph_DeleteCached.c.gcov.html | 137 ++ ...LAGraph_DeleteSelfEdges.c.func-sort-c.html | 76 ++ .../LAGraph_DeleteSelfEdges.c.func.html | 76 ++ .../LAGraph_DeleteSelfEdges.c.gcov.html | 135 ++ .../LAGraph_Finalize.c.func-sort-c.html | 76 ++ src/utility/LAGraph_Finalize.c.func.html | 76 ++ src/utility/LAGraph_Finalize.c.gcov.html | 160 +++ src/utility/LAGraph_Free.c.func-sort-c.html | 76 ++ src/utility/LAGraph_Free.c.func.html | 76 ++ src/utility/LAGraph_Free.c.gcov.html | 115 ++ .../LAGraph_GetNumThreads.c.func-sort-c.html | 76 ++ src/utility/LAGraph_GetNumThreads.c.func.html | 76 ++ src/utility/LAGraph_GetNumThreads.c.gcov.html | 122 ++ .../LAGraph_Graph_Print.c.func-sort-c.html | 76 ++ src/utility/LAGraph_Graph_Print.c.func.html | 76 ++ src/utility/LAGraph_Graph_Print.c.gcov.html | 182 +++ src/utility/LAGraph_Init.c.func-sort-c.html | 76 ++ src/utility/LAGraph_Init.c.func.html | 76 ++ src/utility/LAGraph_Init.c.gcov.html | 103 ++ src/utility/LAGraph_MMRead.c.func-sort-c.html | 100 ++ src/utility/LAGraph_MMRead.c.func.html | 100 ++ src/utility/LAGraph_MMRead.c.gcov.html | 1127 +++++++++++++++++ .../LAGraph_MMWrite.c.func-sort-c.html | 80 ++ src/utility/LAGraph_MMWrite.c.func.html | 80 ++ src/utility/LAGraph_MMWrite.c.gcov.html | 649 ++++++++++ src/utility/LAGraph_Malloc.c.func-sort-c.html | 76 ++ src/utility/LAGraph_Malloc.c.func.html | 76 ++ src/utility/LAGraph_Malloc.c.gcov.html | 128 ++ .../LAGraph_Matrix_IsEqual.c.func-sort-c.html | 76 ++ .../LAGraph_Matrix_IsEqual.c.func.html | 76 ++ .../LAGraph_Matrix_IsEqual.c.gcov.html | 237 ++++ ...AGraph_Matrix_IsEqualOp.c.func-sort-c.html | 76 ++ .../LAGraph_Matrix_IsEqualOp.c.func.html | 76 ++ .../LAGraph_Matrix_IsEqualOp.c.gcov.html | 199 +++ .../LAGraph_Matrix_Print.c.func-sort-c.html | 120 ++ src/utility/LAGraph_Matrix_Print.c.func.html | 120 ++ src/utility/LAGraph_Matrix_Print.c.gcov.html | 283 +++++ ...AGraph_Matrix_Structure.c.func-sort-c.html | 76 ++ .../LAGraph_Matrix_Structure.c.func.html | 76 ++ .../LAGraph_Matrix_Structure.c.gcov.html | 139 ++ .../LAGraph_NameOfType.c.func-sort-c.html | 76 ++ src/utility/LAGraph_NameOfType.c.func.html | 76 ++ src/utility/LAGraph_NameOfType.c.gcov.html | 142 +++ src/utility/LAGraph_New.c.func-sort-c.html | 76 ++ src/utility/LAGraph_New.c.func.html | 76 ++ src/utility/LAGraph_New.c.gcov.html | 171 +++ .../LAGraph_Realloc.c.func-sort-c.html | 76 ++ src/utility/LAGraph_Realloc.c.func.html | 76 ++ src/utility/LAGraph_Realloc.c.gcov.html | 219 ++++ .../LAGraph_SetNumThreads.c.func-sort-c.html | 76 ++ src/utility/LAGraph_SetNumThreads.c.func.html | 76 ++ src/utility/LAGraph_SetNumThreads.c.gcov.html | 131 ++ .../LAGraph_SizeOfType.c.func-sort-c.html | 76 ++ src/utility/LAGraph_SizeOfType.c.func.html | 76 ++ src/utility/LAGraph_SizeOfType.c.gcov.html | 150 +++ .../LAGraph_TypeFromName.c.func-sort-c.html | 76 ++ src/utility/LAGraph_TypeFromName.c.func.html | 76 ++ src/utility/LAGraph_TypeFromName.c.gcov.html | 154 +++ .../LAGraph_TypeName.c.func-sort-c.html | 84 ++ src/utility/LAGraph_TypeName.c.func.html | 84 ++ src/utility/LAGraph_TypeName.c.gcov.html | 232 ++++ .../LAGraph_Vector_IsEqual.c.func-sort-c.html | 76 ++ .../LAGraph_Vector_IsEqual.c.func.html | 76 ++ .../LAGraph_Vector_IsEqual.c.gcov.html | 241 ++++ ...AGraph_Vector_IsEqualOp.c.func-sort-c.html | 76 ++ .../LAGraph_Vector_IsEqualOp.c.func.html | 76 ++ .../LAGraph_Vector_IsEqualOp.c.gcov.html | 199 +++ .../LAGraph_Vector_Print.c.func-sort-c.html | 120 ++ src/utility/LAGraph_Vector_Print.c.func.html | 120 ++ src/utility/LAGraph_Vector_Print.c.gcov.html | 282 +++++ ...AGraph_Vector_Structure.c.func-sort-c.html | 76 ++ .../LAGraph_Vector_Structure.c.func.html | 76 ++ .../LAGraph_Vector_Structure.c.gcov.html | 137 ++ .../LAGraph_Version.c.func-sort-c.html | 76 ++ src/utility/LAGraph_Version.c.func.html | 76 ++ src/utility/LAGraph_Version.c.gcov.html | 135 ++ .../LAGraph_WallClockTime.c.func-sort-c.html | 76 ++ src/utility/LAGraph_WallClockTime.c.func.html | 76 ++ src/utility/LAGraph_WallClockTime.c.gcov.html | 169 +++ src/utility/LG_KindName.c.func-sort-c.html | 76 ++ src/utility/LG_KindName.c.func.html | 76 ++ src/utility/LG_KindName.c.gcov.html | 125 ++ src/utility/LG_Random.c.func-sort-c.html | 80 ++ src/utility/LG_Random.c.func.html | 80 ++ src/utility/LG_Random.c.gcov.html | 113 ++ src/utility/LG_internal.h.func-sort-c.html | 80 ++ src/utility/LG_internal.h.func.html | 80 ++ src/utility/LG_internal.h.gcov.html | 698 ++++++++++ src/utility/LG_msort1.c.func-sort-c.html | 88 ++ src/utility/LG_msort1.c.func.html | 88 ++ src/utility/LG_msort1.c.gcov.html | 547 ++++++++ src/utility/LG_msort2.c.func-sort-c.html | 88 ++ src/utility/LG_msort2.c.func.html | 88 ++ src/utility/LG_msort2.c.gcov.html | 565 +++++++++ src/utility/LG_msort3.c.func-sort-c.html | 88 ++ src/utility/LG_msort3.c.func.html | 88 ++ src/utility/LG_msort3.c.gcov.html | 578 +++++++++ src/utility/LG_nself_edges.c.func-sort-c.html | 76 ++ src/utility/LG_nself_edges.c.func.html | 76 ++ src/utility/LG_nself_edges.c.gcov.html | 167 +++ src/utility/LG_qsort_1a.c.func-sort-c.html | 76 ++ src/utility/LG_qsort_1a.c.func.html | 76 ++ src/utility/LG_qsort_1a.c.gcov.html | 134 ++ src/utility/LG_qsort_2.c.func-sort-c.html | 76 ++ src/utility/LG_qsort_2.c.func.html | 76 ++ src/utility/LG_qsort_2.c.gcov.html | 137 ++ src/utility/LG_qsort_3.c.func-sort-c.html | 76 ++ src/utility/LG_qsort_3.c.func.html | 76 ++ src/utility/LG_qsort_3.c.gcov.html | 140 ++ .../LG_qsort_template.h.func-sort-c.html | 96 ++ src/utility/LG_qsort_template.h.func.html | 96 ++ src/utility/LG_qsort_template.h.gcov.html | 206 +++ src/utility/index-sort-f.html | 593 +++++++++ src/utility/index-sort-l.html | 593 +++++++++ src/utility/index.html | 593 +++++++++ updown.png | Bin 0 -> 117 bytes 532 files changed, 83273 insertions(+) create mode 100644 amber.png create mode 100644 emerald.png create mode 100644 experimental/algorithm/LAGraph_AllKCore.c.func-sort-c.html create mode 100644 experimental/algorithm/LAGraph_AllKCore.c.func.html create mode 100644 experimental/algorithm/LAGraph_AllKCore.c.gcov.html create mode 100644 experimental/algorithm/LAGraph_AllKTruss.c.func-sort-c.html create mode 100644 experimental/algorithm/LAGraph_AllKTruss.c.func.html create mode 100644 experimental/algorithm/LAGraph_AllKTruss.c.gcov.html create mode 100644 experimental/algorithm/LAGraph_BF_basic.c.func-sort-c.html create mode 100644 experimental/algorithm/LAGraph_BF_basic.c.func.html create mode 100644 experimental/algorithm/LAGraph_BF_basic.c.gcov.html create mode 100644 experimental/algorithm/LAGraph_BF_basic_mxv.c.func-sort-c.html create mode 100644 experimental/algorithm/LAGraph_BF_basic_mxv.c.func.html create mode 100644 experimental/algorithm/LAGraph_BF_basic_mxv.c.gcov.html create mode 100644 experimental/algorithm/LAGraph_BF_basic_pushpull.c.func-sort-c.html create mode 100644 experimental/algorithm/LAGraph_BF_basic_pushpull.c.func.html create mode 100644 experimental/algorithm/LAGraph_BF_basic_pushpull.c.gcov.html create mode 100644 experimental/algorithm/LAGraph_BF_full.c.func-sort-c.html create mode 100644 experimental/algorithm/LAGraph_BF_full.c.func.html create mode 100644 experimental/algorithm/LAGraph_BF_full.c.gcov.html create mode 100644 experimental/algorithm/LAGraph_BF_full1.c.func-sort-c.html create mode 100644 experimental/algorithm/LAGraph_BF_full1.c.func.html create mode 100644 experimental/algorithm/LAGraph_BF_full1.c.gcov.html create mode 100644 experimental/algorithm/LAGraph_BF_full1a.c.func-sort-c.html create mode 100644 experimental/algorithm/LAGraph_BF_full1a.c.func.html create mode 100644 experimental/algorithm/LAGraph_BF_full1a.c.gcov.html create mode 100644 experimental/algorithm/LAGraph_BF_full2.c.func-sort-c.html create mode 100644 experimental/algorithm/LAGraph_BF_full2.c.func.html create mode 100644 experimental/algorithm/LAGraph_BF_full2.c.gcov.html create mode 100644 experimental/algorithm/LAGraph_BF_full_mxv.c.func-sort-c.html create mode 100644 experimental/algorithm/LAGraph_BF_full_mxv.c.func.html create mode 100644 experimental/algorithm/LAGraph_BF_full_mxv.c.gcov.html create mode 100644 experimental/algorithm/LAGraph_BF_pure_c.c.func-sort-c.html create mode 100644 experimental/algorithm/LAGraph_BF_pure_c.c.func.html create mode 100644 experimental/algorithm/LAGraph_BF_pure_c.c.gcov.html create mode 100644 experimental/algorithm/LAGraph_BF_pure_c_double.c.func-sort-c.html create mode 100644 experimental/algorithm/LAGraph_BF_pure_c_double.c.func.html create mode 100644 experimental/algorithm/LAGraph_BF_pure_c_double.c.gcov.html create mode 100644 experimental/algorithm/LAGraph_FastGraphletTransform.c.func-sort-c.html create mode 100644 experimental/algorithm/LAGraph_FastGraphletTransform.c.func.html create mode 100644 experimental/algorithm/LAGraph_FastGraphletTransform.c.gcov.html create mode 100644 experimental/algorithm/LAGraph_HelloWorld.c.func-sort-c.html create mode 100644 experimental/algorithm/LAGraph_HelloWorld.c.func.html create mode 100644 experimental/algorithm/LAGraph_HelloWorld.c.gcov.html create mode 100644 experimental/algorithm/LAGraph_KCore.c.func-sort-c.html create mode 100644 experimental/algorithm/LAGraph_KCore.c.func.html create mode 100644 experimental/algorithm/LAGraph_KCore.c.gcov.html create mode 100644 experimental/algorithm/LAGraph_KCoreDecompose.c.func-sort-c.html create mode 100644 experimental/algorithm/LAGraph_KCoreDecompose.c.func.html create mode 100644 experimental/algorithm/LAGraph_KCoreDecompose.c.gcov.html create mode 100644 experimental/algorithm/LAGraph_KTruss.c.func-sort-c.html create mode 100644 experimental/algorithm/LAGraph_KTruss.c.func.html create mode 100644 experimental/algorithm/LAGraph_KTruss.c.gcov.html create mode 100644 experimental/algorithm/LAGraph_MaximalIndependentSet.c.func-sort-c.html create mode 100644 experimental/algorithm/LAGraph_MaximalIndependentSet.c.func.html create mode 100644 experimental/algorithm/LAGraph_MaximalIndependentSet.c.gcov.html create mode 100644 experimental/algorithm/LAGraph_SquareClustering.c.func-sort-c.html create mode 100644 experimental/algorithm/LAGraph_SquareClustering.c.func.html create mode 100644 experimental/algorithm/LAGraph_SquareClustering.c.gcov.html create mode 100644 experimental/algorithm/LAGraph_VertexCentrality_Triangle.c.func-sort-c.html create mode 100644 experimental/algorithm/LAGraph_VertexCentrality_Triangle.c.func.html create mode 100644 experimental/algorithm/LAGraph_VertexCentrality_Triangle.c.gcov.html create mode 100644 experimental/algorithm/LAGraph_cc_lacc.c.func-sort-c.html create mode 100644 experimental/algorithm/LAGraph_cc_lacc.c.func.html create mode 100644 experimental/algorithm/LAGraph_cc_lacc.c.gcov.html create mode 100644 experimental/algorithm/LAGraph_cdlp.c.func-sort-c.html create mode 100644 experimental/algorithm/LAGraph_cdlp.c.func.html create mode 100644 experimental/algorithm/LAGraph_cdlp.c.gcov.html create mode 100644 experimental/algorithm/LAGraph_dnn.c.func-sort-c.html create mode 100644 experimental/algorithm/LAGraph_dnn.c.func.html create mode 100644 experimental/algorithm/LAGraph_dnn.c.gcov.html create mode 100644 experimental/algorithm/LAGraph_lcc.c.func-sort-c.html create mode 100644 experimental/algorithm/LAGraph_lcc.c.func.html create mode 100644 experimental/algorithm/LAGraph_lcc.c.gcov.html create mode 100644 experimental/algorithm/LAGraph_msf.c.func-sort-c.html create mode 100644 experimental/algorithm/LAGraph_msf.c.func.html create mode 100644 experimental/algorithm/LAGraph_msf.c.gcov.html create mode 100644 experimental/algorithm/LAGraph_scc.c.func-sort-c.html create mode 100644 experimental/algorithm/LAGraph_scc.c.func.html create mode 100644 experimental/algorithm/LAGraph_scc.c.gcov.html create mode 100644 experimental/algorithm/LG_CC_FastSV5.c.func-sort-c.html create mode 100644 experimental/algorithm/LG_CC_FastSV5.c.func.html create mode 100644 experimental/algorithm/LG_CC_FastSV5.c.gcov.html create mode 100644 experimental/algorithm/index-sort-f.html create mode 100644 experimental/algorithm/index-sort-l.html create mode 100644 experimental/algorithm/index.html create mode 100644 experimental/test/LG_check_kcore.c.func-sort-c.html create mode 100644 experimental/test/LG_check_kcore.c.func.html create mode 100644 experimental/test/LG_check_kcore.c.gcov.html create mode 100644 experimental/test/LG_check_kcoredecompose.c.func-sort-c.html create mode 100644 experimental/test/LG_check_kcoredecompose.c.func.html create mode 100644 experimental/test/LG_check_kcoredecompose.c.gcov.html create mode 100644 experimental/test/LG_check_ktruss.c.func-sort-c.html create mode 100644 experimental/test/LG_check_ktruss.c.func.html create mode 100644 experimental/test/LG_check_ktruss.c.gcov.html create mode 100644 experimental/test/LG_check_mis.c.func-sort-c.html create mode 100644 experimental/test/LG_check_mis.c.func.html create mode 100644 experimental/test/LG_check_mis.c.gcov.html create mode 100644 experimental/test/index-sort-f.html create mode 100644 experimental/test/index-sort-l.html create mode 100644 experimental/test/index.html create mode 100644 experimental/test/test_AllKCore.c.func-sort-c.html create mode 100644 experimental/test/test_AllKCore.c.func.html create mode 100644 experimental/test/test_AllKCore.c.gcov.html create mode 100644 experimental/test/test_AllKtruss.c.func-sort-c.html create mode 100644 experimental/test/test_AllKtruss.c.func.html create mode 100644 experimental/test/test_AllKtruss.c.gcov.html create mode 100644 experimental/test/test_BF.c.func-sort-c.html create mode 100644 experimental/test/test_BF.c.func.html create mode 100644 experimental/test/test_BF.c.gcov.html create mode 100644 experimental/test/test_FastGraphletTransform.c.func-sort-c.html create mode 100644 experimental/test/test_FastGraphletTransform.c.func.html create mode 100644 experimental/test/test_FastGraphletTransform.c.gcov.html create mode 100644 experimental/test/test_HelloWorld.c.func-sort-c.html create mode 100644 experimental/test/test_HelloWorld.c.func.html create mode 100644 experimental/test/test_HelloWorld.c.gcov.html create mode 100644 experimental/test/test_KCore.c.func-sort-c.html create mode 100644 experimental/test/test_KCore.c.func.html create mode 100644 experimental/test/test_KCore.c.gcov.html create mode 100644 experimental/test/test_KCoreDecompose.c.func-sort-c.html create mode 100644 experimental/test/test_KCoreDecompose.c.func.html create mode 100644 experimental/test/test_KCoreDecompose.c.gcov.html create mode 100644 experimental/test/test_KTruss.c.func-sort-c.html create mode 100644 experimental/test/test_KTruss.c.func.html create mode 100644 experimental/test/test_KTruss.c.gcov.html create mode 100644 experimental/test/test_MaximalIndependentSet.c.func-sort-c.html create mode 100644 experimental/test/test_MaximalIndependentSet.c.func.html create mode 100644 experimental/test/test_MaximalIndependentSet.c.gcov.html create mode 100644 experimental/test/test_Random.c.func-sort-c.html create mode 100644 experimental/test/test_Random.c.func.html create mode 100644 experimental/test/test_Random.c.gcov.html create mode 100644 experimental/test/test_Random_Matrix.c.func-sort-c.html create mode 100644 experimental/test/test_Random_Matrix.c.func.html create mode 100644 experimental/test/test_Random_Matrix.c.gcov.html create mode 100644 experimental/test/test_SSaveSet.c.func-sort-c.html create mode 100644 experimental/test/test_SSaveSet.c.func.html create mode 100644 experimental/test/test_SSaveSet.c.gcov.html create mode 100644 experimental/test/test_SWrite.c.func-sort-c.html create mode 100644 experimental/test/test_SWrite.c.func.html create mode 100644 experimental/test/test_SWrite.c.gcov.html create mode 100644 experimental/test/test_SquareClustering.c.func-sort-c.html create mode 100644 experimental/test/test_SquareClustering.c.func.html create mode 100644 experimental/test/test_SquareClustering.c.gcov.html create mode 100644 experimental/test/test_TriangleCentrality.c.func-sort-c.html create mode 100644 experimental/test/test_TriangleCentrality.c.func.html create mode 100644 experimental/test/test_TriangleCentrality.c.gcov.html create mode 100644 experimental/test/test_cdlp.c.func-sort-c.html create mode 100644 experimental/test/test_cdlp.c.func.html create mode 100644 experimental/test/test_cdlp.c.gcov.html create mode 100644 experimental/test/test_dnn.c.func-sort-c.html create mode 100644 experimental/test/test_dnn.c.func.html create mode 100644 experimental/test/test_dnn.c.gcov.html create mode 100644 experimental/test/test_lcc.c.func-sort-c.html create mode 100644 experimental/test/test_lcc.c.func.html create mode 100644 experimental/test/test_lcc.c.gcov.html create mode 100644 experimental/test/test_msf.c.func-sort-c.html create mode 100644 experimental/test/test_msf.c.func.html create mode 100644 experimental/test/test_msf.c.gcov.html create mode 100644 experimental/test/test_scc.c.func-sort-c.html create mode 100644 experimental/test/test_scc.c.func.html create mode 100644 experimental/test/test_scc.c.gcov.html create mode 100644 experimental/utility/LAGraph_Random.c.func-sort-c.html create mode 100644 experimental/utility/LAGraph_Random.c.func.html create mode 100644 experimental/utility/LAGraph_Random.c.gcov.html create mode 100644 experimental/utility/LAGraph_Random_Matrix.c.func-sort-c.html create mode 100644 experimental/utility/LAGraph_Random_Matrix.c.func.html create mode 100644 experimental/utility/LAGraph_Random_Matrix.c.gcov.html create mode 100644 experimental/utility/LAGraph_SFreeContents.c.func-sort-c.html create mode 100644 experimental/utility/LAGraph_SFreeContents.c.func.html create mode 100644 experimental/utility/LAGraph_SFreeContents.c.gcov.html create mode 100644 experimental/utility/LAGraph_SFreeSet.c.func-sort-c.html create mode 100644 experimental/utility/LAGraph_SFreeSet.c.func.html create mode 100644 experimental/utility/LAGraph_SFreeSet.c.gcov.html create mode 100644 experimental/utility/LAGraph_SLoadSet.c.func-sort-c.html create mode 100644 experimental/utility/LAGraph_SLoadSet.c.func.html create mode 100644 experimental/utility/LAGraph_SLoadSet.c.gcov.html create mode 100644 experimental/utility/LAGraph_SRead.c.func-sort-c.html create mode 100644 experimental/utility/LAGraph_SRead.c.func.html create mode 100644 experimental/utility/LAGraph_SRead.c.gcov.html create mode 100644 experimental/utility/LAGraph_SSaveSet.c.func-sort-c.html create mode 100644 experimental/utility/LAGraph_SSaveSet.c.func.html create mode 100644 experimental/utility/LAGraph_SSaveSet.c.gcov.html create mode 100644 experimental/utility/LAGraph_SWrite.c.func-sort-c.html create mode 100644 experimental/utility/LAGraph_SWrite.c.func.html create mode 100644 experimental/utility/LAGraph_SWrite.c.gcov.html create mode 100644 experimental/utility/index-sort-f.html create mode 100644 experimental/utility/index-sort-l.html create mode 100644 experimental/utility/index.html create mode 100644 gcov.css create mode 100644 glass.png create mode 100644 index-sort-f.html create mode 100644 index-sort-l.html create mode 100644 index.html create mode 100644 ruby.png create mode 100644 snow.png create mode 100644 src/algorithm/LAGr_Betweenness.c.func-sort-c.html create mode 100644 src/algorithm/LAGr_Betweenness.c.func.html create mode 100644 src/algorithm/LAGr_Betweenness.c.gcov.html create mode 100644 src/algorithm/LAGr_BreadthFirstSearch.c.func-sort-c.html create mode 100644 src/algorithm/LAGr_BreadthFirstSearch.c.func.html create mode 100644 src/algorithm/LAGr_BreadthFirstSearch.c.gcov.html create mode 100644 src/algorithm/LAGr_ConnectedComponents.c.func-sort-c.html create mode 100644 src/algorithm/LAGr_ConnectedComponents.c.func.html create mode 100644 src/algorithm/LAGr_ConnectedComponents.c.gcov.html create mode 100644 src/algorithm/LAGr_PageRank.c.func-sort-c.html create mode 100644 src/algorithm/LAGr_PageRank.c.func.html create mode 100644 src/algorithm/LAGr_PageRank.c.gcov.html create mode 100644 src/algorithm/LAGr_PageRankGAP.c.func-sort-c.html create mode 100644 src/algorithm/LAGr_PageRankGAP.c.func.html create mode 100644 src/algorithm/LAGr_PageRankGAP.c.gcov.html create mode 100644 src/algorithm/LAGr_SingleSourceShortestPath.c.func-sort-c.html create mode 100644 src/algorithm/LAGr_SingleSourceShortestPath.c.func.html create mode 100644 src/algorithm/LAGr_SingleSourceShortestPath.c.gcov.html create mode 100644 src/algorithm/LAGr_TriangleCount.c.func-sort-c.html create mode 100644 src/algorithm/LAGr_TriangleCount.c.func.html create mode 100644 src/algorithm/LAGr_TriangleCount.c.gcov.html create mode 100644 src/algorithm/LAGraph_TriangleCount.c.func-sort-c.html create mode 100644 src/algorithm/LAGraph_TriangleCount.c.func.html create mode 100644 src/algorithm/LAGraph_TriangleCount.c.gcov.html create mode 100644 src/algorithm/LG_BreadthFirstSearch_SSGrB.c.func-sort-c.html create mode 100644 src/algorithm/LG_BreadthFirstSearch_SSGrB.c.func.html create mode 100644 src/algorithm/LG_BreadthFirstSearch_SSGrB.c.gcov.html create mode 100644 src/algorithm/LG_BreadthFirstSearch_vanilla.c.func-sort-c.html create mode 100644 src/algorithm/LG_BreadthFirstSearch_vanilla.c.func.html create mode 100644 src/algorithm/LG_BreadthFirstSearch_vanilla.c.gcov.html create mode 100644 src/algorithm/LG_CC_Boruvka.c.func-sort-c.html create mode 100644 src/algorithm/LG_CC_Boruvka.c.func.html create mode 100644 src/algorithm/LG_CC_Boruvka.c.gcov.html create mode 100644 src/algorithm/LG_CC_FastSV6.c.func-sort-c.html create mode 100644 src/algorithm/LG_CC_FastSV6.c.func.html create mode 100644 src/algorithm/LG_CC_FastSV6.c.gcov.html create mode 100644 src/algorithm/index-sort-f.html create mode 100644 src/algorithm/index-sort-l.html create mode 100644 src/algorithm/index.html create mode 100644 src/test/LG_brutal_malloc.c.func-sort-c.html create mode 100644 src/test/LG_brutal_malloc.c.func.html create mode 100644 src/test/LG_brutal_malloc.c.gcov.html create mode 100644 src/test/LG_brutal_setup.c.func-sort-c.html create mode 100644 src/test/LG_brutal_setup.c.func.html create mode 100644 src/test/LG_brutal_setup.c.gcov.html create mode 100644 src/test/LG_brutal_teardown.c.func-sort-c.html create mode 100644 src/test/LG_brutal_teardown.c.func.html create mode 100644 src/test/LG_brutal_teardown.c.gcov.html create mode 100644 src/test/LG_check_bfs.c.func-sort-c.html create mode 100644 src/test/LG_check_bfs.c.func.html create mode 100644 src/test/LG_check_bfs.c.gcov.html create mode 100644 src/test/LG_check_cc.c.func-sort-c.html create mode 100644 src/test/LG_check_cc.c.func.html create mode 100644 src/test/LG_check_cc.c.gcov.html create mode 100644 src/test/LG_check_export.c.func-sort-c.html create mode 100644 src/test/LG_check_export.c.func.html create mode 100644 src/test/LG_check_export.c.gcov.html create mode 100644 src/test/LG_check_sssp.c.func-sort-c.html create mode 100644 src/test/LG_check_sssp.c.func.html create mode 100644 src/test/LG_check_sssp.c.gcov.html create mode 100644 src/test/LG_check_tri.c.func-sort-c.html create mode 100644 src/test/LG_check_tri.c.func.html create mode 100644 src/test/LG_check_tri.c.gcov.html create mode 100644 src/test/LG_check_vector.c.func-sort-c.html create mode 100644 src/test/LG_check_vector.c.func.html create mode 100644 src/test/LG_check_vector.c.gcov.html create mode 100644 src/test/LG_heap.h.func-sort-c.html create mode 100644 src/test/LG_heap.h.func.html create mode 100644 src/test/LG_heap.h.gcov.html create mode 100644 src/test/index-sort-f.html create mode 100644 src/test/index-sort-l.html create mode 100644 src/test/index.html create mode 100644 src/test/test_Betweenness.c.func-sort-c.html create mode 100644 src/test/test_Betweenness.c.func.html create mode 100644 src/test/test_Betweenness.c.gcov.html create mode 100644 src/test/test_BreadthFirstSearch.c.func-sort-c.html create mode 100644 src/test/test_BreadthFirstSearch.c.func.html create mode 100644 src/test/test_BreadthFirstSearch.c.gcov.html create mode 100644 src/test/test_Cached_AT.c.func-sort-c.html create mode 100644 src/test/test_Cached_AT.c.func.html create mode 100644 src/test/test_Cached_AT.c.gcov.html create mode 100644 src/test/test_Cached_Degree.c.func-sort-c.html create mode 100644 src/test/test_Cached_Degree.c.func.html create mode 100644 src/test/test_Cached_Degree.c.gcov.html create mode 100644 src/test/test_Cached_NDiag.c.func-sort-c.html create mode 100644 src/test/test_Cached_NDiag.c.func.html create mode 100644 src/test/test_Cached_NDiag.c.gcov.html create mode 100644 src/test/test_Cached_SymmetricStructure.c.func-sort-c.html create mode 100644 src/test/test_Cached_SymmetricStructure.c.func.html create mode 100644 src/test/test_Cached_SymmetricStructure.c.gcov.html create mode 100644 src/test/test_CheckGraph.c.func-sort-c.html create mode 100644 src/test/test_CheckGraph.c.func.html create mode 100644 src/test/test_CheckGraph.c.gcov.html create mode 100644 src/test/test_ConnectedComponents.c.func-sort-c.html create mode 100644 src/test/test_ConnectedComponents.c.func.html create mode 100644 src/test/test_ConnectedComponents.c.gcov.html create mode 100644 src/test/test_DeleteCached.c.func-sort-c.html create mode 100644 src/test/test_DeleteCached.c.func.html create mode 100644 src/test/test_DeleteCached.c.gcov.html create mode 100644 src/test/test_DisplayGraph.c.func-sort-c.html create mode 100644 src/test/test_DisplayGraph.c.func.html create mode 100644 src/test/test_DisplayGraph.c.gcov.html create mode 100644 src/test/test_Init.c.func-sort-c.html create mode 100644 src/test/test_Init.c.func.html create mode 100644 src/test/test_Init.c.gcov.html create mode 100644 src/test/test_Init_errors.c.func-sort-c.html create mode 100644 src/test/test_Init_errors.c.func.html create mode 100644 src/test/test_Init_errors.c.gcov.html create mode 100644 src/test/test_IsEqual.c.func-sort-c.html create mode 100644 src/test/test_IsEqual.c.func.html create mode 100644 src/test/test_IsEqual.c.gcov.html create mode 100644 src/test/test_KindName.c.func-sort-c.html create mode 100644 src/test/test_KindName.c.func.html create mode 100644 src/test/test_KindName.c.gcov.html create mode 100644 src/test/test_MMRead.c.func-sort-c.html create mode 100644 src/test/test_MMRead.c.func.html create mode 100644 src/test/test_MMRead.c.gcov.html create mode 100644 src/test/test_Malloc.c.func-sort-c.html create mode 100644 src/test/test_Malloc.c.func.html create mode 100644 src/test/test_Malloc.c.gcov.html create mode 100644 src/test/test_Matrix_Structure.c.func-sort-c.html create mode 100644 src/test/test_Matrix_Structure.c.func.html create mode 100644 src/test/test_Matrix_Structure.c.gcov.html create mode 100644 src/test/test_Multiply_size_t.c.func-sort-c.html create mode 100644 src/test/test_Multiply_size_t.c.func.html create mode 100644 src/test/test_Multiply_size_t.c.gcov.html create mode 100644 src/test/test_New.c.func-sort-c.html create mode 100644 src/test/test_New.c.func.html create mode 100644 src/test/test_New.c.gcov.html create mode 100644 src/test/test_NumThreads.c.func-sort-c.html create mode 100644 src/test/test_NumThreads.c.func.html create mode 100644 src/test/test_NumThreads.c.gcov.html create mode 100644 src/test/test_PageRank.c.func-sort-c.html create mode 100644 src/test/test_PageRank.c.func.html create mode 100644 src/test/test_PageRank.c.gcov.html create mode 100644 src/test/test_SampleDegree.c.func-sort-c.html create mode 100644 src/test/test_SampleDegree.c.func.html create mode 100644 src/test/test_SampleDegree.c.gcov.html create mode 100644 src/test/test_SingleSourceShortestPath.c.func-sort-c.html create mode 100644 src/test/test_SingleSourceShortestPath.c.func.html create mode 100644 src/test/test_SingleSourceShortestPath.c.gcov.html create mode 100644 src/test/test_Sort.c.func-sort-c.html create mode 100644 src/test/test_Sort.c.func.html create mode 100644 src/test/test_Sort.c.gcov.html create mode 100644 src/test/test_SortByDegree.c.func-sort-c.html create mode 100644 src/test/test_SortByDegree.c.func.html create mode 100644 src/test/test_SortByDegree.c.gcov.html create mode 100644 src/test/test_TriangleCount.c.func-sort-c.html create mode 100644 src/test/test_TriangleCount.c.func.html create mode 100644 src/test/test_TriangleCount.c.gcov.html create mode 100644 src/test/test_Type.c.func-sort-c.html create mode 100644 src/test/test_Type.c.func.html create mode 100644 src/test/test_Type.c.gcov.html create mode 100644 src/test/test_Vector_Print.c.func-sort-c.html create mode 100644 src/test/test_Vector_Print.c.func.html create mode 100644 src/test/test_Vector_Print.c.gcov.html create mode 100644 src/test/test_Vector_Structure.c.func-sort-c.html create mode 100644 src/test/test_Vector_Structure.c.func.html create mode 100644 src/test/test_Vector_Structure.c.gcov.html create mode 100644 src/test/test_WallClockTime.c.func-sort-c.html create mode 100644 src/test/test_WallClockTime.c.func.html create mode 100644 src/test/test_WallClockTime.c.gcov.html create mode 100644 src/test/test_Xinit.c.func-sort-c.html create mode 100644 src/test/test_Xinit.c.func.html create mode 100644 src/test/test_Xinit.c.gcov.html create mode 100644 src/test/test_acutest.c.func-sort-c.html create mode 100644 src/test/test_acutest.c.func.html create mode 100644 src/test/test_acutest.c.gcov.html create mode 100644 src/test/test_export.c.func-sort-c.html create mode 100644 src/test/test_export.c.func.html create mode 100644 src/test/test_export.c.gcov.html create mode 100644 src/test/test_fopen.c.func-sort-c.html create mode 100644 src/test/test_fopen.c.func.html create mode 100644 src/test/test_fopen.c.gcov.html create mode 100644 src/test/test_minmax.c.func-sort-c.html create mode 100644 src/test/test_minmax.c.func.html create mode 100644 src/test/test_minmax.c.gcov.html create mode 100644 src/test/test_vector.c.func-sort-c.html create mode 100644 src/test/test_vector.c.func.html create mode 100644 src/test/test_vector.c.gcov.html create mode 100644 src/utility/LAGr_Init.c.func-sort-c.html create mode 100644 src/utility/LAGr_Init.c.func.html create mode 100644 src/utility/LAGr_Init.c.gcov.html create mode 100644 src/utility/LAGr_SampleDegree.c.func-sort-c.html create mode 100644 src/utility/LAGr_SampleDegree.c.func.html create mode 100644 src/utility/LAGr_SampleDegree.c.gcov.html create mode 100644 src/utility/LAGr_SortByDegree.c.func-sort-c.html create mode 100644 src/utility/LAGr_SortByDegree.c.func.html create mode 100644 src/utility/LAGr_SortByDegree.c.gcov.html create mode 100644 src/utility/LAGraph_Cached_AT.c.func-sort-c.html create mode 100644 src/utility/LAGraph_Cached_AT.c.func.html create mode 100644 src/utility/LAGraph_Cached_AT.c.gcov.html create mode 100644 src/utility/LAGraph_Cached_EMax.c.func-sort-c.html create mode 100644 src/utility/LAGraph_Cached_EMax.c.func.html create mode 100644 src/utility/LAGraph_Cached_EMax.c.gcov.html create mode 100644 src/utility/LAGraph_Cached_EMin.c.func-sort-c.html create mode 100644 src/utility/LAGraph_Cached_EMin.c.func.html create mode 100644 src/utility/LAGraph_Cached_EMin.c.gcov.html create mode 100644 src/utility/LAGraph_Cached_InDegree.c.func-sort-c.html create mode 100644 src/utility/LAGraph_Cached_InDegree.c.func.html create mode 100644 src/utility/LAGraph_Cached_InDegree.c.gcov.html create mode 100644 src/utility/LAGraph_Cached_IsSymmetricStructure.c.func-sort-c.html create mode 100644 src/utility/LAGraph_Cached_IsSymmetricStructure.c.func.html create mode 100644 src/utility/LAGraph_Cached_IsSymmetricStructure.c.gcov.html create mode 100644 src/utility/LAGraph_Cached_NSelfEdges.c.func-sort-c.html create mode 100644 src/utility/LAGraph_Cached_NSelfEdges.c.func.html create mode 100644 src/utility/LAGraph_Cached_NSelfEdges.c.gcov.html create mode 100644 src/utility/LAGraph_Cached_OutDegree.c.func-sort-c.html create mode 100644 src/utility/LAGraph_Cached_OutDegree.c.func.html create mode 100644 src/utility/LAGraph_Cached_OutDegree.c.gcov.html create mode 100644 src/utility/LAGraph_Calloc.c.func-sort-c.html create mode 100644 src/utility/LAGraph_Calloc.c.func.html create mode 100644 src/utility/LAGraph_Calloc.c.gcov.html create mode 100644 src/utility/LAGraph_CheckGraph.c.func-sort-c.html create mode 100644 src/utility/LAGraph_CheckGraph.c.func.html create mode 100644 src/utility/LAGraph_CheckGraph.c.gcov.html create mode 100644 src/utility/LAGraph_Delete.c.func-sort-c.html create mode 100644 src/utility/LAGraph_Delete.c.func.html create mode 100644 src/utility/LAGraph_Delete.c.gcov.html create mode 100644 src/utility/LAGraph_DeleteCached.c.func-sort-c.html create mode 100644 src/utility/LAGraph_DeleteCached.c.func.html create mode 100644 src/utility/LAGraph_DeleteCached.c.gcov.html create mode 100644 src/utility/LAGraph_DeleteSelfEdges.c.func-sort-c.html create mode 100644 src/utility/LAGraph_DeleteSelfEdges.c.func.html create mode 100644 src/utility/LAGraph_DeleteSelfEdges.c.gcov.html create mode 100644 src/utility/LAGraph_Finalize.c.func-sort-c.html create mode 100644 src/utility/LAGraph_Finalize.c.func.html create mode 100644 src/utility/LAGraph_Finalize.c.gcov.html create mode 100644 src/utility/LAGraph_Free.c.func-sort-c.html create mode 100644 src/utility/LAGraph_Free.c.func.html create mode 100644 src/utility/LAGraph_Free.c.gcov.html create mode 100644 src/utility/LAGraph_GetNumThreads.c.func-sort-c.html create mode 100644 src/utility/LAGraph_GetNumThreads.c.func.html create mode 100644 src/utility/LAGraph_GetNumThreads.c.gcov.html create mode 100644 src/utility/LAGraph_Graph_Print.c.func-sort-c.html create mode 100644 src/utility/LAGraph_Graph_Print.c.func.html create mode 100644 src/utility/LAGraph_Graph_Print.c.gcov.html create mode 100644 src/utility/LAGraph_Init.c.func-sort-c.html create mode 100644 src/utility/LAGraph_Init.c.func.html create mode 100644 src/utility/LAGraph_Init.c.gcov.html create mode 100644 src/utility/LAGraph_MMRead.c.func-sort-c.html create mode 100644 src/utility/LAGraph_MMRead.c.func.html create mode 100644 src/utility/LAGraph_MMRead.c.gcov.html create mode 100644 src/utility/LAGraph_MMWrite.c.func-sort-c.html create mode 100644 src/utility/LAGraph_MMWrite.c.func.html create mode 100644 src/utility/LAGraph_MMWrite.c.gcov.html create mode 100644 src/utility/LAGraph_Malloc.c.func-sort-c.html create mode 100644 src/utility/LAGraph_Malloc.c.func.html create mode 100644 src/utility/LAGraph_Malloc.c.gcov.html create mode 100644 src/utility/LAGraph_Matrix_IsEqual.c.func-sort-c.html create mode 100644 src/utility/LAGraph_Matrix_IsEqual.c.func.html create mode 100644 src/utility/LAGraph_Matrix_IsEqual.c.gcov.html create mode 100644 src/utility/LAGraph_Matrix_IsEqualOp.c.func-sort-c.html create mode 100644 src/utility/LAGraph_Matrix_IsEqualOp.c.func.html create mode 100644 src/utility/LAGraph_Matrix_IsEqualOp.c.gcov.html create mode 100644 src/utility/LAGraph_Matrix_Print.c.func-sort-c.html create mode 100644 src/utility/LAGraph_Matrix_Print.c.func.html create mode 100644 src/utility/LAGraph_Matrix_Print.c.gcov.html create mode 100644 src/utility/LAGraph_Matrix_Structure.c.func-sort-c.html create mode 100644 src/utility/LAGraph_Matrix_Structure.c.func.html create mode 100644 src/utility/LAGraph_Matrix_Structure.c.gcov.html create mode 100644 src/utility/LAGraph_NameOfType.c.func-sort-c.html create mode 100644 src/utility/LAGraph_NameOfType.c.func.html create mode 100644 src/utility/LAGraph_NameOfType.c.gcov.html create mode 100644 src/utility/LAGraph_New.c.func-sort-c.html create mode 100644 src/utility/LAGraph_New.c.func.html create mode 100644 src/utility/LAGraph_New.c.gcov.html create mode 100644 src/utility/LAGraph_Realloc.c.func-sort-c.html create mode 100644 src/utility/LAGraph_Realloc.c.func.html create mode 100644 src/utility/LAGraph_Realloc.c.gcov.html create mode 100644 src/utility/LAGraph_SetNumThreads.c.func-sort-c.html create mode 100644 src/utility/LAGraph_SetNumThreads.c.func.html create mode 100644 src/utility/LAGraph_SetNumThreads.c.gcov.html create mode 100644 src/utility/LAGraph_SizeOfType.c.func-sort-c.html create mode 100644 src/utility/LAGraph_SizeOfType.c.func.html create mode 100644 src/utility/LAGraph_SizeOfType.c.gcov.html create mode 100644 src/utility/LAGraph_TypeFromName.c.func-sort-c.html create mode 100644 src/utility/LAGraph_TypeFromName.c.func.html create mode 100644 src/utility/LAGraph_TypeFromName.c.gcov.html create mode 100644 src/utility/LAGraph_TypeName.c.func-sort-c.html create mode 100644 src/utility/LAGraph_TypeName.c.func.html create mode 100644 src/utility/LAGraph_TypeName.c.gcov.html create mode 100644 src/utility/LAGraph_Vector_IsEqual.c.func-sort-c.html create mode 100644 src/utility/LAGraph_Vector_IsEqual.c.func.html create mode 100644 src/utility/LAGraph_Vector_IsEqual.c.gcov.html create mode 100644 src/utility/LAGraph_Vector_IsEqualOp.c.func-sort-c.html create mode 100644 src/utility/LAGraph_Vector_IsEqualOp.c.func.html create mode 100644 src/utility/LAGraph_Vector_IsEqualOp.c.gcov.html create mode 100644 src/utility/LAGraph_Vector_Print.c.func-sort-c.html create mode 100644 src/utility/LAGraph_Vector_Print.c.func.html create mode 100644 src/utility/LAGraph_Vector_Print.c.gcov.html create mode 100644 src/utility/LAGraph_Vector_Structure.c.func-sort-c.html create mode 100644 src/utility/LAGraph_Vector_Structure.c.func.html create mode 100644 src/utility/LAGraph_Vector_Structure.c.gcov.html create mode 100644 src/utility/LAGraph_Version.c.func-sort-c.html create mode 100644 src/utility/LAGraph_Version.c.func.html create mode 100644 src/utility/LAGraph_Version.c.gcov.html create mode 100644 src/utility/LAGraph_WallClockTime.c.func-sort-c.html create mode 100644 src/utility/LAGraph_WallClockTime.c.func.html create mode 100644 src/utility/LAGraph_WallClockTime.c.gcov.html create mode 100644 src/utility/LG_KindName.c.func-sort-c.html create mode 100644 src/utility/LG_KindName.c.func.html create mode 100644 src/utility/LG_KindName.c.gcov.html create mode 100644 src/utility/LG_Random.c.func-sort-c.html create mode 100644 src/utility/LG_Random.c.func.html create mode 100644 src/utility/LG_Random.c.gcov.html create mode 100644 src/utility/LG_internal.h.func-sort-c.html create mode 100644 src/utility/LG_internal.h.func.html create mode 100644 src/utility/LG_internal.h.gcov.html create mode 100644 src/utility/LG_msort1.c.func-sort-c.html create mode 100644 src/utility/LG_msort1.c.func.html create mode 100644 src/utility/LG_msort1.c.gcov.html create mode 100644 src/utility/LG_msort2.c.func-sort-c.html create mode 100644 src/utility/LG_msort2.c.func.html create mode 100644 src/utility/LG_msort2.c.gcov.html create mode 100644 src/utility/LG_msort3.c.func-sort-c.html create mode 100644 src/utility/LG_msort3.c.func.html create mode 100644 src/utility/LG_msort3.c.gcov.html create mode 100644 src/utility/LG_nself_edges.c.func-sort-c.html create mode 100644 src/utility/LG_nself_edges.c.func.html create mode 100644 src/utility/LG_nself_edges.c.gcov.html create mode 100644 src/utility/LG_qsort_1a.c.func-sort-c.html create mode 100644 src/utility/LG_qsort_1a.c.func.html create mode 100644 src/utility/LG_qsort_1a.c.gcov.html create mode 100644 src/utility/LG_qsort_2.c.func-sort-c.html create mode 100644 src/utility/LG_qsort_2.c.func.html create mode 100644 src/utility/LG_qsort_2.c.gcov.html create mode 100644 src/utility/LG_qsort_3.c.func-sort-c.html create mode 100644 src/utility/LG_qsort_3.c.func.html create mode 100644 src/utility/LG_qsort_3.c.gcov.html create mode 100644 src/utility/LG_qsort_template.h.func-sort-c.html create mode 100644 src/utility/LG_qsort_template.h.func.html create mode 100644 src/utility/LG_qsort_template.h.gcov.html create mode 100644 src/utility/index-sort-f.html create mode 100644 src/utility/index-sort-l.html create mode 100644 src/utility/index.html create mode 100644 updown.png diff --git a/amber.png b/amber.png new file mode 100644 index 0000000000000000000000000000000000000000..2cab170d8359081983a4e343848dfe06bc490f12 GIT binary patch literal 141 zcmeAS@N?(olHy`uVBq!ia0vp^j3CU&3?x-=hn)ga>?NMQuI!iC1^G2tW}LqE04T&+ z;1OBOz`!j8!i<;h*8KqrvZOouIx;Y9?C1WI$O`1M1^9%x{(levWG?NMQuI!iC1^Jb!lvI6;R0X`wF(yt=9xVZRt1vCRixIA4P dLn>}1Cji+@42)0J?}79&c)I$ztaD0e0sy@GAL0N2 literal 0 HcmV?d00001 diff --git a/experimental/algorithm/LAGraph_AllKCore.c.func-sort-c.html b/experimental/algorithm/LAGraph_AllKCore.c.func-sort-c.html new file mode 100644 index 0000000000..a24b38ff6e --- /dev/null +++ b/experimental/algorithm/LAGraph_AllKCore.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_AllKCore.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_AllKCore.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:4949100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_KCore_All6
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_AllKCore.c.func.html b/experimental/algorithm/LAGraph_AllKCore.c.func.html new file mode 100644 index 0000000000..82f6f92f7f --- /dev/null +++ b/experimental/algorithm/LAGraph_AllKCore.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_AllKCore.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_AllKCore.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:4949100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_KCore_All6
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_AllKCore.c.gcov.html b/experimental/algorithm/LAGraph_AllKCore.c.gcov.html new file mode 100644 index 0000000000..22bfca0246 --- /dev/null +++ b/experimental/algorithm/LAGraph_AllKCore.c.gcov.html @@ -0,0 +1,226 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_AllKCore.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_AllKCore.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:4949100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_AllKCore: Full K-core Decomposition Using the GraphBLAS API
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Pranav Konduri, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #define LG_FREE_WORK                \
+      19             : {                                   \
+      20             :     GrB_free (&deg) ;               \
+      21             :     GrB_free (&q) ;                 \
+      22             :     GrB_free (&delta) ;             \
+      23             :     GrB_free (&done) ;              \
+      24             : }
+      25             : 
+      26             : #define LG_FREE_ALL                 \
+      27             : {                                   \
+      28             :     LG_FREE_WORK                    \
+      29             :     GrB_free (decomp) ;             \
+      30             : }
+      31             : 
+      32             : #include "LG_internal.h"
+      33             : 
+      34             : 
+      35           6 : int LAGraph_KCore_All
+      36             : (
+      37             :     // outputs:
+      38             :     GrB_Vector *decomp,     // kcore decomposition
+      39             :     uint64_t *kmax,
+      40             :     // inputs:
+      41             :     LAGraph_Graph G,            // input graph
+      42             :     char *msg
+      43             : )
+      44             : {
+      45           6 :     LG_CLEAR_MSG ;
+      46             : 
+      47             :     // declare items
+      48           6 :     GrB_Matrix A = NULL;
+      49           6 :     GrB_Vector deg = NULL, q = NULL, done = NULL, delta = NULL;
+      50             : 
+      51           6 :     LG_ASSERT (decomp != NULL, GrB_NULL_POINTER) ;
+      52           5 :     (*decomp) = NULL ;
+      53             : 
+      54           5 :     LG_TRY (LAGraph_CheckGraph (G, msg)) ;
+      55             : 
+      56           4 :     if (G->kind == LAGraph_ADJACENCY_UNDIRECTED ||
+      57           2 :        (G->kind == LAGraph_ADJACENCY_DIRECTED &&
+      58           2 :         G->is_symmetric_structure == LAGraph_TRUE))
+      59             :     {
+      60             :          // the structure of A is known to be symmetric
+      61           3 :         A = G->A ;
+      62             :     }
+      63             :     else
+      64             :     {
+      65             :         // A is not known to be symmetric
+      66           1 :         LG_ASSERT_MSG (false, -1005, "G->A must be symmetric") ;
+      67             :     }
+      68             : 
+      69             :     // no self edges can be present
+      70           3 :     LG_ASSERT_MSG (G->nself_edges == 0, -1004, "G->nself_edges must be zero") ;
+      71             : 
+      72             :     //create work scalars
+      73           2 :     uint64_t level = 0; //don't set at 1 in case of empty graph getting returned as kmax = 1
+      74             :     GrB_Index n, todo, nvals, maxDeg ;
+      75           2 :     GRB_TRY (GrB_Matrix_nrows(&n, A)) ;
+      76             : 
+      77             :     //create deg vector using out_degree property
+      78           2 :     LG_TRY (LAGraph_Cached_OutDegree(G, msg)) ;
+      79             : 
+      80           2 :     GRB_TRY (GrB_Vector_dup(&deg, G->out_degree)) ; //original deg vector is technically 1-core since 0 is omitted
+      81           2 :     GRB_TRY (GrB_Vector_nvals(&todo, deg)) ; //use todo instead of n since some values are omitted (1-core)
+      82             : 
+      83             :     //retrieve the max degree level of the graph
+      84           2 :     GRB_TRY (GrB_reduce(&maxDeg, GrB_NULL, GrB_MAX_MONOID_INT64, G->out_degree, GrB_NULL)) ;
+      85             : 
+      86             :     //select int type for work vectors and semirings
+      87           2 :     GrB_Type int_type  = (maxDeg > INT32_MAX) ? GrB_INT64 : GrB_INT32 ;
+      88             : 
+      89           2 :     GRB_TRY (GrB_Vector_new(&q, int_type, n));
+      90           2 :     GRB_TRY (GrB_Vector_new(&done, GrB_BOOL, n)) ;
+      91           2 :     GRB_TRY (GrB_Vector_new(&delta, int_type, n)) ;
+      92             :     //set output to int64
+      93           2 :     GRB_TRY (GrB_Vector_new(decomp, int_type, n)) ;
+      94             : 
+      95             :     //change deg vector to int32 if needed
+      96           2 :     if(int_type == GrB_INT32){
+      97           2 :         GrB_free (&deg) ;
+      98           2 :         GRB_TRY (GrB_Vector_new(&deg, int_type, n)) ;
+      99           2 :         GRB_TRY (GrB_assign (deg, G->out_degree, NULL, G->out_degree, GrB_ALL, n, NULL)) ;
+     100             :     }
+     101             : 
+     102             :     // determine semiring types
+     103           2 :     GrB_IndexUnaryOp valueEQ = (maxDeg > INT32_MAX) ? GrB_VALUEEQ_INT64 : GrB_VALUEEQ_INT32 ;
+     104           2 :     GrB_IndexUnaryOp valueLE = (maxDeg > INT32_MAX) ? GrB_VALUELE_INT64 : GrB_VALUELE_INT32 ;
+     105           2 :     GrB_BinaryOp minus_op = (maxDeg > INT32_MAX) ? GrB_MINUS_INT64 : GrB_MINUS_INT32 ;
+     106           2 :     GrB_Semiring semiring = (maxDeg > INT32_MAX) ? LAGraph_plus_one_int64 : LAGraph_plus_one_int32 ;
+     107             : 
+     108             : #if LG_SUITESPARSE
+     109             :     GRB_TRY (GxB_set (done, GxB_SPARSITY_CONTROL, GxB_BITMAP + GxB_FULL)) ;    // try this
+     110             :     //GRB_TRY (GxB_set (*decomp, GxB_SPARSITY_CONTROL, GxB_BITMAP + GxB_FULL)) ; // try this ... likely not needed...
+     111             : #endif
+     112             : 
+     113             :     //printf ("\n================================== COMPUTING GrB_KCORE: ==================================\n") ;
+     114          12 :     while(todo > 0){
+     115             :         //printf("Level: %ld, todo: %ld\n", level, todo) ;
+     116          10 :         level++;
+     117             :         // Creating q
+     118          10 :         GRB_TRY (GrB_select (q, GrB_NULL, GrB_NULL, valueEQ, deg, level, GrB_NULL)) ; // get all nodes with degree = level
+     119          10 :         GRB_TRY (GrB_Vector_nvals(&nvals, q));
+     120             : 
+     121             :         //Assign values of deg into decomp (output)
+     122          10 :         GRB_TRY (GrB_assign (*decomp, deg, NULL, level, GrB_ALL, n, GrB_NULL)) ;
+     123             : 
+     124          10 :         int round = 0;
+     125             :         // while q not empty
+     126          24 :         while(nvals > 0){
+     127             :             // Decrease todo by number of nvals
+     128          14 :             todo = todo - nvals ;
+     129             :             //add anything in q as true into the done list
+     130          14 :             GRB_TRY (GrB_assign (done, q, NULL, (bool) true, GrB_ALL, n, GrB_DESC_S)) ; //structure to take care of 0-node cases
+     131             : 
+     132             :             // Create delta (the nodes who lost friends, and how many they lost)
+     133          14 :             GRB_TRY (GrB_vxm (delta, GrB_NULL, GrB_NULL, semiring, q, A, GrB_NULL));
+     134             : 
+     135             :             // Create new deg vector (keep anything not in done vector w/ replace command)
+     136          14 :             GRB_TRY (GrB_eWiseAdd(deg, done, GrB_NULL, minus_op, deg, delta, GrB_DESC_RSC /* try GrB_DESC_RSC */)) ;
+     137             : 
+     138             :             // Update q, set new nvals
+     139          14 :             GRB_TRY (GrB_select (q, GrB_NULL, GrB_NULL, valueLE, deg, level, GrB_NULL)) ;
+     140             : 
+     141          14 :             GRB_TRY (GrB_Vector_nvals(&nvals, q)) ;
+     142          14 :             round++;
+     143             :         }
+     144             :     }
+     145             :     //set kmax
+     146           2 :     (*kmax) = level;
+     147             : 
+     148           2 :     LG_FREE_WORK ;
+     149           2 :     return (GrB_SUCCESS) ;
+     150             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_AllKTruss.c.func-sort-c.html b/experimental/algorithm/LAGraph_AllKTruss.c.func-sort-c.html new file mode 100644 index 0000000000..8f0fb04b06 --- /dev/null +++ b/experimental/algorithm/LAGraph_AllKTruss.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_AllKTruss.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_AllKTruss.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:4545100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_AllKTruss22
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_AllKTruss.c.func.html b/experimental/algorithm/LAGraph_AllKTruss.c.func.html new file mode 100644 index 0000000000..e98ab0033d --- /dev/null +++ b/experimental/algorithm/LAGraph_AllKTruss.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_AllKTruss.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_AllKTruss.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:4545100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_AllKTruss22
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_AllKTruss.c.gcov.html b/experimental/algorithm/LAGraph_AllKTruss.c.gcov.html new file mode 100644 index 0000000000..6198e167b9 --- /dev/null +++ b/experimental/algorithm/LAGraph_AllKTruss.c.gcov.html @@ -0,0 +1,256 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_AllKTruss.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_AllKTruss.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:4545100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_AllKTruss.c: find all k-trusses of a graph
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // LAGraph_AllKTruss: find all k-trusses of a graph via GraphBLAS.
+      19             : 
+      20             : // Given a symmetric graph A with no-self edges, LAGraph_AllKTruss finds all
+      21             : // k-trusses of A.
+      22             : 
+      23             : // The output matrices Cset [3..kmax-1] are the k-trusses of A.  Their edges
+      24             : // are a subset of A.  Each edge in C = Cset [k] is part of at least k-2
+      25             : // triangles in C.  The structure of C is the adjacency matrix of the k-truss
+      26             : // subgraph of A.  The edge weights of C are the support of each edge.  That
+      27             : // is, C(i,j)=nt if the edge (i,j) is part of nt triangles in C.  All edges in
+      28             : // C have support of at least k-2.  The total number of triangles in C is
+      29             : // sum(C)/6.  The number of edges in C is nnz(C)/2.  C = Cset [k] is returned
+      30             : // as symmetric with a zero-free diagonal.  Cset [kmax] is an empty matrix
+      31             : // since the kmax-truss is empty.
+      32             : 
+      33             : // The arrays ntris, nedges, and nstepss hold the output statistics.
+      34             : // ntris   [k] = # of triangles in the k-truss
+      35             : // nedges  [k] = # of edges in the k-truss
+      36             : // nstepss [k] = # of steps required to compute the k-truss
+      37             : 
+      38             : // Usage: constructs all k-trusses of A, for k = 3:kmax
+      39             : 
+      40             : //      int64_t kmax ;
+      41             : //      GrB_Matrix_nrows (&n, A) ;
+      42             : //      int64_t n4 = (n > 4) ? n : 4 ;
+      43             : //      GrB_Matrix *Cset = LAGraph_malloc (n4, sizeof (GrB_Matrix)) ;
+      44             : //      int64_t *ntris   = LAGraph_malloc (n4, sizeof (int64_t)) ;
+      45             : //      int64_t *nedges  = LAGraph_malloc (n4, sizeof (int64_t)) ;
+      46             : //      int64_t *nstepss = LAGraph_malloc (n4, sizeof (int64_t)) ;
+      47             : //      int result = LAGraph_AllKTruss (&Cset, &kmax, ntris, nedges,
+      48             : //          nstepss, G, msg) ;
+      49             : 
+      50             : // todo: add experimental/benchmark/ktruss_demo.c to benchmark k-truss
+      51             : // and all-k-truss
+      52             : 
+      53             : // todo: consider LAGraph_KTrussNext to compute the (k+1)-truss from the
+      54             : // k-truss
+      55             : 
+      56             : #define LG_FREE_ALL                         \
+      57             : {                                           \
+      58             :     for (int64_t kk = 3 ; kk <= k ; kk++)   \
+      59             :     {                                       \
+      60             :         GrB_free (&(Cset [kk])) ;           \
+      61             :     }                                       \
+      62             : }
+      63             : 
+      64             : #include "LG_internal.h"
+      65             : #include "LAGraphX.h"
+      66             : 
+      67             : //------------------------------------------------------------------------------
+      68             : // C = LAGraph_AllKTruss: find all k-trusses a graph
+      69             : //------------------------------------------------------------------------------
+      70             : 
+      71          22 : int LAGraph_AllKTruss   // compute all k-trusses of a graph
+      72             : (
+      73             :     // outputs
+      74             :     GrB_Matrix *Cset,   // size n, output k-truss subgraphs
+      75             :     int64_t *kmax,      // smallest k where k-truss is empty
+      76             :     int64_t *ntris,     // size max(n,4), ntris [k] is #triangles in k-truss
+      77             :     int64_t *nedges,    // size max(n,4), nedges [k] is #edges in k-truss
+      78             :     int64_t *nstepss,   // size max(n,4), nstepss [k] is #steps for k-truss
+      79             :     // input
+      80             :     LAGraph_Graph G,    // input graph
+      81             :     char *msg
+      82             : )
+      83             : {
+      84             : 
+      85             :     //--------------------------------------------------------------------------
+      86             :     // check inputs
+      87             :     //--------------------------------------------------------------------------
+      88             : 
+      89          22 :     LG_CLEAR_MSG ;
+      90          22 :     int64_t k = 0 ;
+      91          22 :     LG_ASSERT (Cset != NULL && nstepss != NULL, GrB_NULL_POINTER) ;
+      92          22 :     LG_ASSERT (kmax != NULL && ntris != NULL, GrB_NULL_POINTER) ;
+      93          21 :     LG_ASSERT (nedges != NULL, GrB_NULL_POINTER) ;
+      94          21 :     LG_TRY (LAGraph_CheckGraph (G, msg)) ;
+      95             : 
+      96          20 :     if (G->kind == LAGraph_ADJACENCY_UNDIRECTED ||
+      97          10 :        (G->kind == LAGraph_ADJACENCY_DIRECTED &&
+      98          10 :         G->is_symmetric_structure == LAGraph_TRUE))
+      99             :     {
+     100             :         // the structure of A is known to be symmetric
+     101             :         ;
+     102             :     }
+     103             :     else
+     104             :     {
+     105             :         // A is not known to be symmetric
+     106           1 :         LG_ASSERT_MSG (false, -1005, "G->A must be symmetric") ;
+     107             :     }
+     108             : 
+     109             :     // no self edges can be present
+     110          19 :     LG_ASSERT_MSG (G->nself_edges == 0, -1004, "G->nself_edges must be zero") ;
+     111             : 
+     112             :     //--------------------------------------------------------------------------
+     113             :     // initializations
+     114             :     //--------------------------------------------------------------------------
+     115             : 
+     116          90 :     for (k = 0 ; k <= 3 ; k++)
+     117             :     {
+     118          72 :         Cset [k] = NULL ;
+     119          72 :         ntris   [k] = 0 ;
+     120          72 :         nedges  [k] = 0 ;
+     121          72 :         nstepss [k] = 0 ;
+     122             :     }
+     123          18 :     k = 3 ;
+     124          18 :     (*kmax) = 0 ;
+     125             : 
+     126             :     //--------------------------------------------------------------------------
+     127             :     // initialzations
+     128             :     //--------------------------------------------------------------------------
+     129             : 
+     130             :     GrB_Index n ;
+     131          18 :     GrB_Matrix S = G->A ;
+     132          18 :     GRB_TRY (GrB_Matrix_nrows (&n, S)) ;
+     133          18 :     GRB_TRY (GrB_Matrix_new (&(Cset [k]), GrB_UINT32, n, n)) ;
+     134          18 :     GrB_Matrix C = Cset [k] ;
+     135             :     GrB_Index nvals, nvals_last ;
+     136          18 :     GRB_TRY (GrB_Matrix_nvals (&nvals_last, S)) ;
+     137          18 :     int64_t nsteps = 0 ;
+     138             : 
+     139             :     //--------------------------------------------------------------------------
+     140             :     // find all k-trusses
+     141             :     //--------------------------------------------------------------------------
+     142             : 
+     143             :     while (true)
+     144             :     {
+     145             :         // C{S} = S*S'
+     146         434 :         GRB_TRY (GrB_mxm (C, S, NULL, LAGraph_plus_one_uint32, S, S,
+     147             :             GrB_DESC_RST1)) ;
+     148             :         // keep entries in C that are >= k-2
+     149         434 :         GRB_TRY (GrB_select (C, NULL, NULL, GrB_VALUEGE_UINT32, C, k-2, NULL)) ;
+     150         434 :         nsteps++ ;
+     151             :         // check if k-truss has been found
+     152         434 :         GRB_TRY (GrB_Matrix_nvals (&nvals, C)) ;
+     153         434 :         if (nvals == nvals_last)
+     154             :         {
+     155             :             // k-truss has been found
+     156          96 :             int64_t nt = 0 ;
+     157         114 :             GRB_TRY (GrB_reduce (&nt, NULL, GrB_PLUS_MONOID_INT64, C, NULL)) ;
+     158          96 :             ntris   [k] = nt / 6 ;
+     159          96 :             nedges  [k] = nvals / 2 ;
+     160          96 :             nstepss [k] = nsteps ;
+     161          96 :             nsteps = 0 ;
+     162          96 :             if (nvals == 0)
+     163             :             {
+     164             :                 // this is the last k-truss
+     165          18 :                 (*kmax) = k ;
+     166          18 :                 return (GrB_SUCCESS) ;
+     167             :             }
+     168          78 :             S = C ;             // S = current k-truss for k+1 iteration
+     169          78 :             k++ ;               // advance to the next k-tryss
+     170          78 :             GRB_TRY (GrB_Matrix_new (&(Cset [k]), GrB_UINT32, n, n)) ;
+     171          78 :             C = Cset [k] ;      // C = new matrix for next k-truss
+     172             :         }
+     173             :         else
+     174             :         {
+     175             :             // advance to the next step, still computing the current k-truss
+     176         338 :             nvals_last = nvals ;
+     177         338 :             S = C ;
+     178             :         }
+     179             :     }
+     180             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_BF_basic.c.func-sort-c.html b/experimental/algorithm/LAGraph_BF_basic.c.func-sort-c.html new file mode 100644 index 0000000000..317b8eb615 --- /dev/null +++ b/experimental/algorithm/LAGraph_BF_basic.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_BF_basic.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_BF_basic.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3737100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_BF_basic5
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_BF_basic.c.func.html b/experimental/algorithm/LAGraph_BF_basic.c.func.html new file mode 100644 index 0000000000..8d919f1540 --- /dev/null +++ b/experimental/algorithm/LAGraph_BF_basic.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_BF_basic.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_BF_basic.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3737100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_BF_basic5
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_BF_basic.c.gcov.html b/experimental/algorithm/LAGraph_BF_basic.c.gcov.html new file mode 100644 index 0000000000..d723f98fd4 --- /dev/null +++ b/experimental/algorithm/LAGraph_BF_basic.c.gcov.html @@ -0,0 +1,205 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_BF_basic.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_BF_basic.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3737100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_BF_basic: Bellman-Ford method for single source shortest paths
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Jinhao Chen and Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // LAGraph_BF_basic: Bellman-Ford single source shortest paths, returning just
+      19             : // the shortest path lengths.
+      20             : 
+      21             : // LAGraph_BF_basic performs a Bellman-Ford to find out shortest path length
+      22             : // from given source vertex s in the range of [0, n) on graph given as matrix A
+      23             : // with size n by n. The sparse matrix A has entry A(i, j) if there is edge from
+      24             : // vertex i to vertex j with weight w, then A(i, j) = w. Furthermore,
+      25             : // LAGraph_BF_basic requires A(i, i) = 0 for all 0 <= i < n.
+      26             : 
+      27             : // LAGraph_BF_basic returns GrB_SUCCESS regardless of existence of
+      28             : // negative-weight cycle. However, the GrB_Vector d(k) (i.e., *pd_output) will
+      29             : // be NULL when negative-weight cycle detected. Otherwise, the vector d has
+      30             : // d(k) as the shortest distance from s to k.
+      31             : 
+      32             : //------------------------------------------------------------------------------
+      33             : 
+      34             : #define LG_FREE_ALL        \
+      35             : {                          \
+      36             :     GrB_free(&d) ;         \
+      37             :     GrB_free(&dtmp) ;      \
+      38             : }
+      39             : 
+      40             : #include "LG_internal.h"
+      41             : #include <LAGraphX.h>
+      42             : 
+      43             : // Given a n-by-n adjacency matrix A and a source vertex s.
+      44             : // If there is no negative-weight cycle reachable from s, return the distances
+      45             : // of shortest paths from s as vector d. Otherwise, return d=NULL if there is
+      46             : // negative-weight cycle.
+      47             : // pd_output = &d, where d is a GrB_Vector with d(k) as the shortest distance
+      48             : // from s to k when no negative-weight cycle detected, otherwise, d = NULL.
+      49             : // A has zeros on diagonal and weights on corresponding entries of edges
+      50             : // s is given index for source vertex
+      51           5 : GrB_Info LAGraph_BF_basic
+      52             : (
+      53             :     GrB_Vector *pd_output,      //the pointer to the vector of distance
+      54             :     const GrB_Matrix A,         //matrix for the graph
+      55             :     const GrB_Index s           //given index of the source
+      56             : )
+      57             : {
+      58             :     GrB_Info info;
+      59           5 :     char *msg = NULL ;
+      60             :     GrB_Index nrows, ncols;
+      61             :     // tmp vector to store distance vector after n (i.e., V) loops
+      62           5 :     GrB_Vector d = NULL, dtmp = NULL;
+      63             : 
+      64           5 :     LG_ASSERT (A != NULL && pd_output != NULL, GrB_NULL_POINTER) ;
+      65             : 
+      66           5 :     *pd_output = NULL;
+      67           5 :     GRB_TRY (GrB_Matrix_nrows (&nrows, A)) ;
+      68           5 :     GRB_TRY (GrB_Matrix_ncols (&ncols, A)) ;
+      69           5 :     LG_ASSERT_MSG (nrows == ncols, -1002, "A must be square") ;
+      70           5 :     GrB_Index n = nrows;           // n = # of vertices in graph
+      71           5 :     LG_ASSERT_MSG (s < n, GrB_INVALID_INDEX, "invalid source node") ;
+      72             : 
+      73             :     // Initialize distance vector, change the d[s] to 0
+      74           5 :     GRB_TRY (GrB_Vector_new(&d, GrB_FP64, n));
+      75           5 :     GRB_TRY (GrB_Vector_setElement_FP64(d, 0, s));
+      76             : 
+      77             :     // copy d to dtmp in order to create a same size of vector
+      78           5 :     GRB_TRY (GrB_Vector_dup(&dtmp, d));
+      79             : 
+      80           5 :     int64_t iter = 0;      //number of iterations
+      81           5 :     bool same = false;     //variable indicating if d=dtmp
+      82             : 
+      83             :     // terminate when no new path is found or more than n-1 loops
+      84          93 :     while (!same && iter < n - 1)
+      85             :     {
+      86             : 
+      87          88 :         double t = LAGraph_WallClockTime ( ) ;
+      88             : 
+      89             :         // execute semiring on d and A, and save the result to d
+      90          88 :         GRB_TRY (GrB_vxm(dtmp, GrB_NULL, GrB_NULL, GrB_MIN_PLUS_SEMIRING_FP64, d, A,
+      91             :             GrB_NULL));
+      92          88 :         LG_TRY (LAGraph_Vector_IsEqual (&same, dtmp, d, NULL));
+      93          88 :         if (!same)
+      94             :         {
+      95          85 :             GrB_Vector ttmp = dtmp;
+      96          85 :             dtmp = d;
+      97          85 :             d = ttmp;
+      98             :         }
+      99          88 :         iter++;
+     100          88 :         t = LAGraph_WallClockTime ( ) - t ;
+     101             :         GrB_Index dnz ;
+     102          88 :         GRB_TRY (GrB_Vector_nvals (&dnz, d)) ;
+     103             : //      printf ("step %3d time %16.4f sec, nvals %.16g\n", iter, t, (double) dnz);
+     104          88 :         fflush (stdout) ;
+     105             :     }
+     106             : 
+     107             :     // check for negative-weight cycle only when there was a new path in the
+     108             :     // last loop, otherwise, there can't be a negative-weight cycle.
+     109           5 :     if (!same)
+     110             :     {
+     111             :         // execute semiring again to check for negative-weight cycle
+     112           2 :         GRB_TRY (GrB_vxm(dtmp, GrB_NULL, GrB_NULL, GrB_MIN_PLUS_SEMIRING_FP64, d, A,
+     113             :             GrB_NULL));
+     114           2 :         LG_TRY (LAGraph_Vector_IsEqual (&same, dtmp, d, NULL));
+     115             : 
+     116             :         // if d != dtmp, then there is a negative-weight cycle in the graph
+     117           2 :         if (!same)
+     118             :         {
+     119             :             // printf("A negative-weight cycle found. \n");
+     120           2 :             LG_FREE_ALL;
+     121           2 :             return (GrB_NO_VALUE) ;
+     122             :         }
+     123             :     }
+     124             : 
+     125           3 :     (*pd_output) = d;
+     126           3 :     d = NULL;
+     127           3 :     LG_FREE_ALL;
+     128           3 :     return (GrB_SUCCESS) ;
+     129             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_BF_basic_mxv.c.func-sort-c.html b/experimental/algorithm/LAGraph_BF_basic_mxv.c.func-sort-c.html new file mode 100644 index 0000000000..232accbcbb --- /dev/null +++ b/experimental/algorithm/LAGraph_BF_basic_mxv.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_BF_basic_mxv.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_BF_basic_mxv.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3333100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_BF_basic_mxv5
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_BF_basic_mxv.c.func.html b/experimental/algorithm/LAGraph_BF_basic_mxv.c.func.html new file mode 100644 index 0000000000..861dbc0d59 --- /dev/null +++ b/experimental/algorithm/LAGraph_BF_basic_mxv.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_BF_basic_mxv.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_BF_basic_mxv.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3333100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_BF_basic_mxv5
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_BF_basic_mxv.c.gcov.html b/experimental/algorithm/LAGraph_BF_basic_mxv.c.gcov.html new file mode 100644 index 0000000000..db4c98ba81 --- /dev/null +++ b/experimental/algorithm/LAGraph_BF_basic_mxv.c.gcov.html @@ -0,0 +1,208 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_BF_basic_mxv.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_BF_basic_mxv.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3333100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_BF_basic: Bellman-Ford method for single source shortest paths
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Jinhao Chen and Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // LAGraph_BF_basic_mxv: Bellman-Ford single source shortest paths, returning
+      19             : // just the shortest path lengths.
+      20             : 
+      21             : // LAGraph_BF_basic_mxv performs a Bellman-Ford to find out shortest path length
+      22             : // from given source vertex s in the range of [0, n) on graph with n nodes.
+      23             : // It works almost the same as LAGraph_BF_basic except that it performs update
+      24             : // using GrB_mxv instead of GrB_vxm, therefore, it require the input matrix as
+      25             : // the transpose of adjacency matrix A with size n by n. That is, the input
+      26             : // sparse matrix has entry AT(i, j) if there is edge from vertex j to vertex i
+      27             : // with weight w, then AT(i, j) = w. While same as LAGraph_BF_basic, it requires
+      28             : // AT(i, i) = 0 for all 0 <= i < n.
+      29             : 
+      30             : // LAGraph_BF_basic_mxv returns GrB_SUCCESS if it succeeds. In this case, there
+      31             : // are no negative-weight cycles in the graph, and the vector d is returned.
+      32             : // d(k) is the shortest distance from s to k.
+      33             : 
+      34             : // If the graph has a negative-weight cycle, GrB_NO_VALUE is returned, and the
+      35             : // GrB_Vector d (i.e., *pd_output) will be NULL.
+      36             : 
+      37             : // Otherwise, other errors such as GrB_OUT_OF_MEMORY, GrB_INVALID_OBJECT, and
+      38             : // so on, can be returned, if these errors are found by the underlying
+      39             : // GrB_* functions.
+      40             : //------------------------------------------------------------------------------
+      41             : 
+      42             : #define LG_FREE_ALL        \
+      43             : {                          \
+      44             :     GrB_free(&d) ;         \
+      45             :     GrB_free(&dtmp) ;      \
+      46             : }
+      47             : 
+      48             : #include <LAGraph.h>
+      49             : #include <LAGraphX.h>
+      50             : #include <LG_internal.h>  // from src/utility
+      51             : 
+      52             : 
+      53             : // Given the transposed of a n-by-n adjacency matrix A and a source vertex s.
+      54             : // If there is no negative-weight cycle reachable from s, return the distances
+      55             : // of shortest paths from s as vector d. Otherwise, return d=NULL if there is
+      56             : // negative-weight cycle.
+      57             : // pd_output = &d, where d is a GrB_Vector with d(k) as the shortest distance
+      58             : // from s to k when no negative-weight cycle detected, otherwise, d = NULL.
+      59             : // AT has zeros on diagonal and weights on corresponding entries of edges
+      60             : // s is given index for source vertex
+      61           5 : GrB_Info LAGraph_BF_basic_mxv
+      62             : (
+      63             :     GrB_Vector *pd_output,      //the pointer to the vector of distance
+      64             :     const GrB_Matrix AT,        //transposed adjacency matrix for the graph
+      65             :     const GrB_Index s           //given index of the source
+      66             : )
+      67             : {
+      68             :     GrB_Info info;
+      69           5 :     char *msg = NULL ;
+      70             :     GrB_Index nrows, ncols;
+      71             :     // tmp vector to store distance vector after n loops
+      72           5 :     GrB_Vector d = NULL, dtmp = NULL;
+      73             : 
+      74           5 :     LG_ASSERT (AT != NULL && pd_output != NULL, GrB_NULL_POINTER) ;
+      75             : 
+      76           5 :     *pd_output = NULL;
+      77           5 :     GRB_TRY (GrB_Matrix_nrows (&nrows, AT)) ;
+      78           5 :     GRB_TRY (GrB_Matrix_ncols (&ncols, AT)) ;
+      79           5 :     LG_ASSERT_MSG (nrows == ncols, -1002, "AT must be square") ;
+      80           5 :     GrB_Index n = nrows;           // n = # of vertices in graph
+      81           5 :     LG_ASSERT_MSG (s < n, GrB_INVALID_INDEX, "invalid source node") ;
+      82             : 
+      83             :     // Initialize distance vector, change the d[s] to 0
+      84           5 :     GRB_TRY (GrB_Vector_new(&d, GrB_FP64, n));
+      85           5 :     GRB_TRY (GrB_Vector_setElement_FP64(d, 0, s));
+      86             : 
+      87             :     // copy d to dtmp in order to create a same size of vector
+      88           5 :     GRB_TRY (GrB_Vector_dup(&dtmp, d));
+      89             : 
+      90           5 :     int64_t iter = 0;      //number of iterations
+      91           5 :     bool same = false;     //variable indicating if d == dtmp
+      92             : 
+      93             :     // terminate when no new path is found or more than n-1 loops
+      94          93 :     while (!same && iter < n - 1)
+      95             :     {
+      96             :         // excute semiring on d and AT, and save the result to d
+      97          88 :         GRB_TRY (GrB_mxv(dtmp, GrB_NULL, GrB_NULL, GrB_MIN_PLUS_SEMIRING_FP64,
+      98             :             AT, d, GrB_NULL));
+      99             : 
+     100          88 :         LG_TRY (LAGraph_Vector_IsEqual (&same, dtmp, d, NULL));
+     101          88 :         if (!same)
+     102             :         {
+     103          85 :             GrB_Vector ttmp = dtmp;
+     104          85 :             dtmp = d;
+     105          85 :             d = ttmp;
+     106             :         }
+     107          88 :         iter++;
+     108             :     }
+     109             : 
+     110             :     // check for negative-weight cycle only when there was a new path in the
+     111             :     // last loop, otherwise, there can't be a negative-weight cycle.
+     112           5 :     if (!same)
+     113             :     {
+     114             :         // excute semiring again to check for negative-weight cycle
+     115           2 :         GRB_TRY (GrB_mxv(dtmp, GrB_NULL, GrB_NULL, GrB_MIN_PLUS_SEMIRING_FP64,
+     116             :             AT, d, GrB_NULL));
+     117             : 
+     118             :         // if d != dtmp, then there is a negative-weight cycle in the graph
+     119           2 :         LG_TRY (LAGraph_Vector_IsEqual (&same, dtmp, d, NULL));
+     120           2 :         if (!same)
+     121             :         {
+     122             :             // printf("AT negative-weight cycle found. \n");
+     123           2 :             LG_FREE_ALL;
+     124           2 :             return (GrB_NO_VALUE) ;
+     125             :         }
+     126             :     }
+     127             : 
+     128           3 :     (*pd_output) = d;
+     129           3 :     d = NULL;
+     130           3 :     LG_FREE_ALL;
+     131           3 :     return (GrB_SUCCESS) ;
+     132             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_BF_basic_pushpull.c.func-sort-c.html b/experimental/algorithm/LAGraph_BF_basic_pushpull.c.func-sort-c.html new file mode 100644 index 0000000000..3f416ae062 --- /dev/null +++ b/experimental/algorithm/LAGraph_BF_basic_pushpull.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_BF_basic_pushpull.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_BF_basic_pushpull.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:6969100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_BF_basic_pushpull15
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_BF_basic_pushpull.c.func.html b/experimental/algorithm/LAGraph_BF_basic_pushpull.c.func.html new file mode 100644 index 0000000000..fe21a3d071 --- /dev/null +++ b/experimental/algorithm/LAGraph_BF_basic_pushpull.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_BF_basic_pushpull.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_BF_basic_pushpull.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:6969100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_BF_basic_pushpull15
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_BF_basic_pushpull.c.gcov.html b/experimental/algorithm/LAGraph_BF_basic_pushpull.c.gcov.html new file mode 100644 index 0000000000..0ad4b34067 --- /dev/null +++ b/experimental/algorithm/LAGraph_BF_basic_pushpull.c.gcov.html @@ -0,0 +1,315 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_BF_basic_pushpull.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_BF_basic_pushpull.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:6969100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_BF_basic_pushpull: Bellman-Ford method for single source shortest
+       3             : // paths
+       4             : //------------------------------------------------------------------------------
+       5             : 
+       6             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       7             : // SPDX-License-Identifier: BSD-2-Clause
+       8             : //
+       9             : // For additional details (including references to third party source code and
+      10             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      11             : // Contributors.txt for a full list of contributors. Created, in part, with
+      12             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      13             : // DM22-0790
+      14             : 
+      15             : // Contributed by Jinhao Chen and Timothy A. Davis, Texas A&M University
+      16             : 
+      17             : //------------------------------------------------------------------------------
+      18             : 
+      19             : // This is the fastest variant that computes just the path lengths,
+      20             : // and not the parent vector.
+      21             : 
+      22             : // LAGraph_BF_basic_pushpull: Bellman-Ford single source shortest paths,
+      23             : // returning just the shortest path lengths.
+      24             : 
+      25             : // LAGraph_BF_basic_pushpull performs a Bellman-Ford to find out shortest path
+      26             : // length from given source vertex s in the range of [0, n) on graph given as
+      27             : // matrix A with size n by n. The sparse matrix A has entry A(i, j) if there is
+      28             : // edge from vertex i to vertex j with weight w, then A(i, j) = w. Furthermore,
+      29             : // LAGraph_BF_basic requires A(i, i) = 0 for all 0 <= i < n.
+      30             : 
+      31             : // LAGraph_BF_basic returns GrB_SUCCESS if successful, or GrB_NO_VALUE if it
+      32             : // detects a negative-weight cycle.  The GrB_Vector d(k) (i.e., *pd_output)
+      33             : // will be NULL when negative-weight cycle detected. Otherwise, the vector d
+      34             : // has d(k) as the shortest distance from s to k.
+      35             : 
+      36             : // todo: this is a candidate for inclusion as a src/algorithm
+      37             : 
+      38             : //------------------------------------------------------------------------------
+      39             : 
+      40             : #define LG_FREE_ALL        \
+      41             : {                          \
+      42             :     GrB_free(&d) ;         \
+      43             :     GrB_free(&dtmp) ;      \
+      44             : }
+      45             : 
+      46             : #include <LAGraph.h>
+      47             : #include <LAGraphX.h>
+      48             : #include <LG_internal.h>  // from src/utility
+      49             : 
+      50             : 
+      51             : // Given a n-by-n adjacency matrix A and a source vertex s.
+      52             : // If there is no negative-weight cycle reachable from s, return the distances
+      53             : // of shortest paths from s as vector d. Otherwise, return d=NULL if there is
+      54             : // negative-weight cycle.
+      55             : // pd_output = &d, where d is a GrB_Vector with d(k) as the shortest distance
+      56             : // from s to k when no negative-weight cycle detected, otherwise, d = NULL.
+      57             : 
+      58             : // A must have explicit zeros on the diagonal and weights on corresponding
+      59             : // entries of edges.  s is given index for source vertex.
+      60             : 
+      61          15 : GrB_Info LAGraph_BF_basic_pushpull
+      62             : (
+      63             :     GrB_Vector *pd_output,      //the pointer to the vector of distance
+      64             :     const GrB_Matrix A,         //matrix for the graph
+      65             :     const GrB_Matrix AT,        //transpose of A (optional)
+      66             :     const GrB_Index s           //given index of the source
+      67             : )
+      68             : {
+      69             :     GrB_Info info;
+      70          15 :     char *msg = NULL ;
+      71             :     GrB_Index nrows, ncols, nvalA;
+      72             :     // tmp vector to store distance vector after n (i.e., V) loops
+      73          15 :     GrB_Vector d = NULL, dtmp = NULL;
+      74             : 
+      75          15 :     LG_ASSERT ((A != NULL || AT != NULL) && pd_output != NULL,
+      76             :         GrB_NULL_POINTER);
+      77             : 
+      78          15 :     (*pd_output) = NULL;
+      79             :     bool use_vxm_with_A;
+      80          15 :     if (A == NULL)
+      81             :     {
+      82           5 :         GRB_TRY (GrB_Matrix_nrows (&nrows, AT)) ;
+      83           5 :         GRB_TRY (GrB_Matrix_ncols (&ncols, AT)) ;
+      84           5 :         GRB_TRY (GrB_Matrix_nvals (&nvalA, AT)) ;
+      85           5 :         use_vxm_with_A = false;
+      86             :     }
+      87             :     else
+      88             :     {
+      89          10 :         GRB_TRY (GrB_Matrix_nrows (&nrows, A)) ;
+      90          10 :         GRB_TRY (GrB_Matrix_ncols (&ncols, A)) ;
+      91          10 :         GRB_TRY (GrB_Matrix_nvals (&nvalA, A)) ;
+      92          10 :         use_vxm_with_A = true;
+      93             :     }
+      94             : 
+      95             :     // push/pull requires both A and AT
+      96          15 :     bool push_pull = (A != NULL && AT != NULL) ;
+      97             : 
+      98          15 :     LG_ASSERT_MSG (nrows == ncols, -1002, "A must be square") ;
+      99             : 
+     100          15 :     GrB_Index n = nrows;           // n = # of vertices in graph
+     101             :     // average node degree
+     102          15 :     double dA = (n == 0) ? 0 : (((double) nvalA) / (double) n) ;
+     103             : 
+     104          15 :     LG_ASSERT_MSG (s < n, GrB_INVALID_INDEX, "invalid source node") ;
+     105             : 
+     106             :     // values used to determine if d should be converted to dense
+     107             :     // dthreshold is used when only A or AT is available
+     108             :     int64_t dthreshold ;
+     109          15 :     if (A == NULL)
+     110             :     {
+     111           5 :         dthreshold =  LAGRAPH_MAX (256, sqrt ((double) n)) ;
+     112             :     }
+     113             :     else
+     114             :     {
+     115          10 :         dthreshold = n/2;
+     116             :     }
+     117             :     // refer to GraphBLAS/Source/GB_AxB_select.c
+     118             :     // convert d to dense when GB_AxB_select intend to use Gustavson
+     119          15 :     size_t csize = sizeof(double) + sizeof(int64_t) ;
+     120          15 :     double gs_memory = ((double) n * (double) csize)/1e9 ;
+     121             : 
+     122          15 :     bool dsparse = true;
+     123             : 
+     124             :     // Initialize distance vector, change the d[s] to 0
+     125          15 :     GRB_TRY (GrB_Vector_new(&d, GrB_FP64, n));
+     126          15 :     GRB_TRY (GrB_Vector_setElement_FP64(d, 0, s));
+     127             :     // copy d to dtmp in order to create a same size of vector
+     128          15 :     GRB_TRY (GrB_Vector_dup(&dtmp, d));
+     129             : 
+     130          15 :     int64_t iter = 0;      //number of iterations
+     131          15 :     bool same = false;     //variable indicating if d=dtmp
+     132             : 
+     133             :     // terminate when no new path is found or more than n-1 loops
+     134         279 :     while (!same && iter < n - 1)
+     135             :     {
+     136             : 
+     137             :         // double t2 = LAGraph_WallClockTime ( ) ;
+     138             : 
+     139             :         // excute semiring on d and A, and save the result to d
+     140         264 :         if (!use_vxm_with_A)
+     141             :         {
+     142         171 :             GRB_TRY (GrB_mxv (dtmp, NULL, NULL, GrB_MIN_PLUS_SEMIRING_FP64,
+     143             :                 AT, d, NULL));
+     144             :         }
+     145             :         else
+     146             :         {
+     147          93 :             GRB_TRY (GrB_vxm (dtmp, NULL, NULL, GrB_MIN_PLUS_SEMIRING_FP64,
+     148             :                 d, A, NULL));
+     149             :         }
+     150         264 :         LG_TRY (LAGraph_Vector_IsEqual (&same, dtmp, d, NULL));
+     151         264 :         if (!same)
+     152             :         {
+     153         255 :             GrB_Vector ttmp = dtmp;
+     154         255 :             dtmp = d;
+     155         255 :             d = ttmp;
+     156             :         }
+     157         264 :         iter++;
+     158             : 
+     159             :         // t2 = LAGraph_WallClockTime ( ) - t2 ;
+     160             : 
+     161             :         GrB_Index dnz ;
+     162         264 :         GRB_TRY (GrB_Vector_nvals (&dnz, d)) ;
+     163             : 
+     164         264 :         if (dsparse)
+     165             :         {
+     166         105 :             if (!push_pull)
+     167             :             {
+     168         100 :                 if (dnz > dthreshold)
+     169             :                 {
+     170           5 :                     dsparse = false;
+     171             :                 }
+     172             :             }
+     173             :             else
+     174             :             {
+     175           5 :                 double heap_memory = (((double) dnz+1) *
+     176           5 :                                      5 * (double) (sizeof(int64_t))) / 1e9;
+     177           5 :                 int log2dnz = 0 ;
+     178          20 :                 while (dnz > 0)
+     179             :                 {
+     180          15 :                     dnz = dnz / 2 ;
+     181          15 :                     log2dnz++ ;
+     182             :                 }
+     183           5 :                 dsparse = (4 * log2dnz * heap_memory < gs_memory);
+     184           5 :                 use_vxm_with_A = dsparse;
+     185             :             }
+     186             : 
+     187         105 :             if (!dsparse)
+     188             :             {
+     189          10 :                 GRB_TRY (GrB_Vector_setElement_FP64(d, 1e-16, s));
+     190          10 :                 GRB_TRY (GrB_assign (d, d, NULL, INFINITY, GrB_ALL, n,
+     191             :                     GrB_DESC_C)) ;
+     192          10 :                 GRB_TRY (GrB_Vector_setElement_FP64(d, 0, s));
+     193             :             }
+     194             :         }
+     195             :     }
+     196             : 
+     197             :     // check for negative-weight cycle only when there was a new path in the
+     198             :     // last loop, otherwise, there can't be a negative-weight cycle.
+     199          15 :     if (!same)
+     200             :     {
+     201             :         // excute semiring again to check for negative-weight cycle
+     202           6 :         if (!use_vxm_with_A)
+     203             :         {
+     204           4 :             GRB_TRY (GrB_mxv(dtmp, NULL, NULL,
+     205             :                 GrB_MIN_PLUS_SEMIRING_FP64, AT, d, NULL));
+     206             :         }
+     207             :         else
+     208             :         {
+     209           2 :             GRB_TRY (GrB_vxm(dtmp, NULL, NULL,
+     210             :                 GrB_MIN_PLUS_SEMIRING_FP64, d, A, NULL));
+     211             :         }
+     212           6 :         LG_TRY (LAGraph_Vector_IsEqual (&same, dtmp, d, NULL));
+     213             : 
+     214             :         // if d != dtmp, then there is a negative-weight cycle in the graph
+     215           6 :         if (!same)
+     216             :         {
+     217             :             // printf("A negative-weight cycle found. \n");
+     218           6 :             LG_FREE_ALL;
+     219           6 :             return (GrB_NO_VALUE) ;
+     220             :         }
+     221             :     }
+     222             : 
+     223             :     //--------------------------------------------------------------------------
+     224             :     // todo: make d sparse
+     225             :     //--------------------------------------------------------------------------
+     226             :     /*if (!dsparse)
+     227             :     {
+     228             :         GRB_TRY (GrB_assign (d, d, NULL, d, GrB_ALL, n, GrB_DESC_R)) ;
+     229             :         GRB_TRY (GrB_Vector_setElement_FP64(d, 0, s));
+     230             :         GrB_Index dnz ;
+     231             :         GRB_TRY (GrB_Vector_nvals (&dnz, d)) ;
+     232             :         printf ("final nvals %.16g\n", (double) dnz) ;
+     233             :     }*/
+     234             : 
+     235           9 :     (*pd_output) = d;
+     236           9 :     d = NULL;
+     237           9 :     LG_FREE_ALL;
+     238           9 :     return (GrB_SUCCESS) ;
+     239             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_BF_full.c.func-sort-c.html b/experimental/algorithm/LAGraph_BF_full.c.func-sort-c.html new file mode 100644 index 0000000000..6caec3c93c --- /dev/null +++ b/experimental/algorithm/LAGraph_BF_full.c.func-sort-c.html @@ -0,0 +1,88 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_BF_full.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_BF_full.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:8989100.0 %
Date:2024-08-29 20:08:04Functions:44100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_BF_full5
BF_EQ4424
BF_lMIN20297
BF_PLUSrhs25194
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_BF_full.c.func.html b/experimental/algorithm/LAGraph_BF_full.c.func.html new file mode 100644 index 0000000000..75c11b3a0b --- /dev/null +++ b/experimental/algorithm/LAGraph_BF_full.c.func.html @@ -0,0 +1,88 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_BF_full.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_BF_full.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:8989100.0 %
Date:2024-08-29 20:08:04Functions:44100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
BF_EQ4424
BF_PLUSrhs25194
BF_lMIN20297
LAGraph_BF_full5
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_BF_full.c.gcov.html b/experimental/algorithm/LAGraph_BF_full.c.gcov.html new file mode 100644 index 0000000000..bcdc2cab25 --- /dev/null +++ b/experimental/algorithm/LAGraph_BF_full.c.gcov.html @@ -0,0 +1,386 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_BF_full.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_BF_full.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:8989100.0 %
Date:2024-08-29 20:08:04Functions:44100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_BF_full.c: Bellman-Ford single-source shortest paths, returns tree
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Jinhao Chen and Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // LAGraph_BF_full: Bellman-Ford single source shortest paths, returning both
+      19             : // the path lengths and the shortest-path tree.
+      20             : 
+      21             : // LAGraph_BF_full performs a Bellman-Ford to find out shortest path, parent
+      22             : // nodes along the path and the hops (number of edges) in the path from given
+      23             : // source vertex s in the range of [0, n) on graph given as matrix A with size
+      24             : // n*n. The sparse matrix A has entry A(i, j) if there is an edge from vertex i
+      25             : // to vertex j with weight w, then A(i, j) = w. Furthermore, LAGraph_BF_full
+      26             : // requires A(i, i) = 0 for all 0 <= i < n.
+      27             : 
+      28             : // LAGraph_BF_full returns GrB_SUCCESS if successful, and GrB_NO_VALUE if it
+      29             : // detects the existence of negative- weight cycle. The GrB_Vector d(k), pi(k)
+      30             : // and h(k)  (i.e., *pd_output, *ppi_output and *ph_output respectively) will
+      31             : // be NULL when negative-weight cycle detected. Otherwise, the vector d has
+      32             : // d(k) as the shortest distance from s to k. pi(k) = p+1, where p is the
+      33             : // parent node of k-th node in the shortest path. In particular, pi(s) = 0.
+      34             : // h(k) = hop(s, k), the number of edges from s to k in the shortest path.
+      35             : 
+      36             : //------------------------------------------------------------------------------
+      37             : 
+      38             : #define LG_FREE_ALL                    \
+      39             : {                                      \
+      40             :     GrB_free(&d);                      \
+      41             :     GrB_free(&dtmp);                   \
+      42             :     GrB_free(&Atmp);                   \
+      43             :     GrB_free(&BF_Tuple3);              \
+      44             :     GrB_free(&BF_lMIN_Tuple3);         \
+      45             :     GrB_free(&BF_PLUSrhs_Tuple3);      \
+      46             :     GrB_free(&BF_EQ_Tuple3);           \
+      47             :     GrB_free(&BF_lMIN_Tuple3_Monoid);  \
+      48             :     GrB_free(&BF_lMIN_PLUSrhs_Tuple3); \
+      49             :     LAGraph_Free ((void**)&I, NULL);   \
+      50             :     LAGraph_Free ((void**)&J, NULL);   \
+      51             :     LAGraph_Free ((void**)&w, NULL);   \
+      52             :     LAGraph_Free ((void**)&W, NULL);   \
+      53             :     LAGraph_Free ((void**)&h, NULL);   \
+      54             :     LAGraph_Free ((void**)&pi, NULL);  \
+      55             : }
+      56             : 
+      57             : #include <LAGraph.h>
+      58             : #include <LAGraphX.h>
+      59             : #include <LG_internal.h>  // from src/utility
+      60             : 
+      61             : typedef void (*LAGraph_binary_function) (void *, const void *, const void *) ;
+      62             : 
+      63             : //------------------------------------------------------------------------------
+      64             : // data type for each entry of the adjacent matrix A and "distance" vector d;
+      65             : // <INFINITY,INFINITY,INFINITY> corresponds to nonexistence of a path, and
+      66             : // the value  <0, 0, NULL> corresponds to a path from a vertex to itself
+      67             : //------------------------------------------------------------------------------
+      68             : typedef struct
+      69             : {
+      70             :     double w;    // w  corresponds to a path weight.
+      71             :     GrB_Index h; // h  corresponds to a path size or number of hops.
+      72             :     GrB_Index pi;// pi corresponds to the penultimate vertex along a path.
+      73             :                  // vertex indexed as 1, 2, 3, ... , V, and pi = 0 (as nil)
+      74             :                  // for u=v, and pi = UINT64_MAX (as inf) for (u,v) not in E
+      75             : }
+      76             : BF_Tuple3_struct;
+      77             : 
+      78             : //------------------------------------------------------------------------------
+      79             : // 2 binary functions, z=f(x,y), where Tuple3xTuple3 -> Tuple3
+      80             : //------------------------------------------------------------------------------
+      81             : 
+      82       20297 : void BF_lMIN
+      83             : (
+      84             :     BF_Tuple3_struct *z,
+      85             :     const BF_Tuple3_struct *x,
+      86             :     const BF_Tuple3_struct *y
+      87             : )
+      88             : {
+      89       20297 :     if (x->w < y->w
+      90        5788 :         || (x->w == y->w && x->h < y->h)
+      91        5788 :         || (x->w == y->w && x->h == y->h && x->pi < y->pi))
+      92             :     {
+      93       14565 :         if (z != x) { *z = *x; }
+      94             :     }
+      95             :     else
+      96             :     {
+      97        5732 :         *z = *y;
+      98             :     }
+      99       20297 : }
+     100             : 
+     101       25194 : void BF_PLUSrhs
+     102             : (
+     103             :     BF_Tuple3_struct *z,
+     104             :     const BF_Tuple3_struct *x,
+     105             :     const BF_Tuple3_struct *y
+     106             : )
+     107             : {
+     108       25194 :     z->w = x->w + y->w ;
+     109       25194 :     z->h = x->h + y->h ;
+     110       25194 :     z->pi = (x->pi != UINT64_MAX && y->pi != 0) ?  y->pi : x->pi ;
+     111       25194 : }
+     112             : 
+     113        4424 : void BF_EQ
+     114             : (
+     115             :     bool *z,
+     116             :     const BF_Tuple3_struct *x,
+     117             :     const BF_Tuple3_struct *y
+     118             : )
+     119             : {
+     120        4424 :     (*z) = (x->w == y->w && x->h == y->h && x->pi == y->pi) ;
+     121        4424 : }
+     122             : 
+     123             : // Given a n-by-n adjacency matrix A and a source vertex s.
+     124             : // If there is no negative-weight cycle reachable from s, return the distances
+     125             : // of shortest paths from s and parents along the paths as vector d. Otherwise,
+     126             : // returns d=NULL if there is a negtive-weight cycle.
+     127             : // pd_output is pointer to a GrB_Vector, where the i-th entry is d(s,i), the
+     128             : //   sum of edges length in the shortest path
+     129             : // ppi_output is pointer to a GrB_Vector, where the i-th entry is pi(i), the
+     130             : //   parent of i-th vertex in the shortest path
+     131             : // ph_output is pointer to a GrB_Vector, where the i-th entry is h(s,i), the
+     132             : //   number of edges from s to i in the shortest path
+     133             : // A has zeros on diagonal and weights on corresponding entries of edges
+     134             : // s is given index for source vertex
+     135           5 : GrB_Info LAGraph_BF_full
+     136             : (
+     137             :     GrB_Vector *pd_output,      //the pointer to the vector of distance
+     138             :     GrB_Vector *ppi_output,     //the pointer to the vector of parent
+     139             :     GrB_Vector *ph_output,       //the pointer to the vector of hops
+     140             :     const GrB_Matrix A,         //matrix for the graph
+     141             :     const GrB_Index s           //given index of the source
+     142             : )
+     143             : {
+     144             :     GrB_Info info;
+     145           5 :     char *msg = NULL ;
+     146             :     // tmp vector to store distance vector after n (i.e., V) loops
+     147           5 :     GrB_Vector d = NULL, dtmp = NULL;
+     148           5 :     GrB_Matrix Atmp = NULL;
+     149             :     GrB_Type BF_Tuple3;
+     150             : 
+     151             :     GrB_BinaryOp BF_lMIN_Tuple3;
+     152             :     GrB_BinaryOp BF_PLUSrhs_Tuple3;
+     153             :     GrB_BinaryOp BF_EQ_Tuple3;
+     154             : 
+     155             :     GrB_Monoid BF_lMIN_Tuple3_Monoid;
+     156             :     GrB_Semiring BF_lMIN_PLUSrhs_Tuple3;
+     157             : 
+     158             :     GrB_Index nrows, ncols, n, nz;  // n = # of row/col, nz = # of nnz in graph
+     159           5 :     GrB_Index *I = NULL, *J = NULL; // for col/row indices of entries from A
+     160           5 :     GrB_Index *h = NULL, *pi = NULL;
+     161           5 :     double *w = NULL;
+     162           5 :     BF_Tuple3_struct *W = NULL;
+     163             : 
+     164           5 :     LG_ASSERT (A != NULL && pd_output != NULL &&
+     165             :         ppi_output != NULL && ph_output != NULL, GrB_NULL_POINTER) ;
+     166             : 
+     167           5 :     *pd_output  = NULL;
+     168           5 :     *ppi_output = NULL;
+     169           5 :     *ph_output  = NULL;
+     170           5 :     GRB_TRY (GrB_Matrix_nrows (&nrows, A)) ;
+     171           5 :     GRB_TRY (GrB_Matrix_ncols (&ncols, A)) ;
+     172           5 :     GRB_TRY (GrB_Matrix_nvals (&nz, A));
+     173           5 :     LG_ASSERT_MSG (nrows == ncols, -1002, "A must be square") ;
+     174           5 :     n = nrows;
+     175           5 :     LG_ASSERT_MSG (s < n, GrB_INVALID_INDEX, "invalid source node") ;
+     176             : 
+     177             :     //--------------------------------------------------------------------------
+     178             :     // create all GrB_Type GrB_BinaryOp GrB_Monoid and GrB_Semiring
+     179             :     //--------------------------------------------------------------------------
+     180             :     // GrB_Type
+     181           5 :     GRB_TRY (GrB_Type_new(&BF_Tuple3, sizeof(BF_Tuple3_struct)));
+     182             : 
+     183             :     // GrB_BinaryOp
+     184           5 :     GRB_TRY (GrB_BinaryOp_new(&BF_EQ_Tuple3,
+     185             :         (LAGraph_binary_function) (&BF_EQ), GrB_BOOL, BF_Tuple3, BF_Tuple3));
+     186           5 :     GRB_TRY (GrB_BinaryOp_new(&BF_lMIN_Tuple3,
+     187             :         (LAGraph_binary_function) (&BF_lMIN), BF_Tuple3, BF_Tuple3, BF_Tuple3));
+     188           5 :     GRB_TRY (GrB_BinaryOp_new(&BF_PLUSrhs_Tuple3,
+     189             :         (LAGraph_binary_function)(&BF_PLUSrhs),
+     190             :         BF_Tuple3, BF_Tuple3, BF_Tuple3));
+     191             : 
+     192             :     // GrB_Monoid
+     193           5 :     BF_Tuple3_struct BF_identity = (BF_Tuple3_struct) { .w = INFINITY,
+     194             :         .h = UINT64_MAX, .pi = UINT64_MAX };
+     195           5 :     GRB_TRY (GrB_Monoid_new_UDT(&BF_lMIN_Tuple3_Monoid, BF_lMIN_Tuple3,
+     196             :         &BF_identity));
+     197             : 
+     198             :     //GrB_Semiring
+     199           5 :     GRB_TRY (GrB_Semiring_new(&BF_lMIN_PLUSrhs_Tuple3,
+     200             :         BF_lMIN_Tuple3_Monoid, BF_PLUSrhs_Tuple3));
+     201             : 
+     202             :     //--------------------------------------------------------------------------
+     203             :     // allocate arrays used for tuplets
+     204             :     //--------------------------------------------------------------------------
+     205             : 
+     206           5 :     LAGRAPH_TRY (LAGraph_Malloc ((void **) &I, nz, sizeof(GrB_Index), msg)) ;
+     207           5 :     LAGRAPH_TRY (LAGraph_Malloc ((void **) &J, nz, sizeof(GrB_Index), msg)) ;
+     208           5 :     LAGRAPH_TRY (LAGraph_Malloc ((void **) &w, nz, sizeof(double), msg)) ;
+     209           5 :     LAGRAPH_TRY (LAGraph_Malloc ((void **) &W, nz, sizeof(BF_Tuple3_struct),
+     210             :         msg)) ;
+     211             : 
+     212             :     //--------------------------------------------------------------------------
+     213             :     // create matrix Atmp based on A, while its entries become BF_Tuple3 type
+     214             :     //--------------------------------------------------------------------------
+     215             : 
+     216           5 :     GRB_TRY (GrB_Matrix_extractTuples_FP64(I, J, w, &nz, A));
+     217             :     int nthreads, nthreads_outer, nthreads_inner ;
+     218           5 :     LG_TRY (LAGraph_GetNumThreads (&nthreads_outer, &nthreads_inner, msg)) ;
+     219           5 :     nthreads = nthreads_outer * nthreads_inner ;
+     220           5 :     printf ("nthreads %d\n", nthreads) ;
+     221             :     int64_t k;
+     222             :     #pragma omp parallel for num_threads(nthreads) schedule(static)
+     223         951 :     for (k = 0; k < nz; k++)
+     224             :     {
+     225         946 :         if (w[k] == 0)             //diagonal entries
+     226             :         {
+     227         184 :             W[k] = (BF_Tuple3_struct) { .w = 0, .h = 0, .pi = 0 };
+     228             :         }
+     229             :         else
+     230             :         {
+     231         762 :             W[k] = (BF_Tuple3_struct) { .w = w[k], .h = 1, .pi = I[k] + 1 };
+     232             :         }
+     233             :     }
+     234           5 :     GRB_TRY (GrB_Matrix_new(&Atmp, BF_Tuple3, n, n));
+     235           5 :     GRB_TRY (GrB_Matrix_build_UDT(Atmp, I, J, W, nz, BF_lMIN_Tuple3));
+     236             : 
+     237             :     //--------------------------------------------------------------------------
+     238             :     // create and initialize "distance" vector d
+     239             :     //--------------------------------------------------------------------------
+     240           5 :     GRB_TRY (GrB_Vector_new(&d, BF_Tuple3, n));
+     241             :     // initial distance from s to itself
+     242           5 :     BF_Tuple3_struct d0 = (BF_Tuple3_struct) { .w = 0, .h = 0, .pi = 0 };
+     243           5 :     GRB_TRY (GrB_Vector_setElement_UDT(d, &d0, s));
+     244             : 
+     245             :     //--------------------------------------------------------------------------
+     246             :     // start the Bellman Ford process
+     247             :     //--------------------------------------------------------------------------
+     248             :     // copy d to dtmp in order to create a same size of vector
+     249           5 :     GRB_TRY (GrB_Vector_dup(&dtmp, d));
+     250           5 :     bool same= false;          // variable indicating if d == dtmp
+     251           5 :     int64_t iter = 0;          // number of iterations
+     252             : 
+     253             :     // terminate when no new path is found or more than V-1 loops
+     254          93 :     while (!same && iter < n - 1)
+     255             :     {
+     256             :         // execute semiring on d and A, and save the result to dtmp
+     257          88 :         GRB_TRY (GrB_vxm(dtmp, GrB_NULL, GrB_NULL, BF_lMIN_PLUSrhs_Tuple3,
+     258             :             d, Atmp, GrB_NULL));
+     259             : 
+     260          88 :         LG_TRY (LAGraph_Vector_IsEqualOp (&same, dtmp, d, BF_EQ_Tuple3, NULL));
+     261          88 :         if (!same)
+     262             :         {
+     263          85 :             GrB_Vector ttmp = dtmp;
+     264          85 :             dtmp = d;
+     265          85 :             d = ttmp;
+     266             :         }
+     267          88 :         iter ++;
+     268             :     }
+     269             : 
+     270             :     // check for negative-weight cycle only when there was a new path in the
+     271             :     // last loop, otherwise, there can't be a negative-weight cycle.
+     272           5 :     if (!same)
+     273             :     {
+     274             :         // execute semiring again to check for negative-weight cycle
+     275           2 :         GRB_TRY (GrB_vxm(dtmp, GrB_NULL, GrB_NULL, BF_lMIN_PLUSrhs_Tuple3,
+     276             :             d, Atmp, GrB_NULL));
+     277             : 
+     278             :         // if d != dtmp, then there is a negative-weight cycle in the graph
+     279           2 :         LG_TRY (LAGraph_Vector_IsEqualOp (&same, dtmp, d, BF_EQ_Tuple3, NULL));
+     280           2 :         if (!same)
+     281             :         {
+     282             :             // printf("A negative-weight cycle found. \n");
+     283           2 :             LG_FREE_ALL;
+     284           2 :             return (GrB_NO_VALUE) ;
+     285             :         }
+     286             :     }
+     287             : 
+     288             :     //--------------------------------------------------------------------------
+     289             :     // extract tuple from "distance" vector d and create GrB_Vectors for output
+     290             :     //--------------------------------------------------------------------------
+     291             : 
+     292           3 :     GRB_TRY (GrB_Vector_extractTuples_UDT (I, (void *) W, &nz, d));
+     293           3 :     LAGRAPH_TRY (LAGraph_Malloc ((void **) &h , nz, sizeof(GrB_Index), msg)) ;
+     294           3 :     LAGRAPH_TRY (LAGraph_Malloc ((void **) &pi, nz, sizeof(GrB_Index), msg)) ;
+     295             : 
+     296         111 :     for (k = 0; k < nz; k++)
+     297             :     {
+     298         108 :         w [k] = W[k].w ;
+     299         108 :         h [k] = W[k].h ;
+     300         108 :         pi[k] = W[k].pi;
+     301             :     }
+     302           3 :     GRB_TRY (GrB_Vector_new(pd_output,  GrB_FP64,   n));
+     303           3 :     GRB_TRY (GrB_Vector_new(ppi_output, GrB_UINT64, n));
+     304           3 :     GRB_TRY (GrB_Vector_new(ph_output,  GrB_UINT64, n));
+     305           3 :     GRB_TRY (GrB_Vector_build_FP64  (*pd_output , I, w , nz,GrB_MIN_FP64  ));
+     306           3 :     GRB_TRY (GrB_Vector_build_UINT64(*ppi_output, I, pi, nz,GrB_MIN_UINT64));
+     307           3 :     GRB_TRY (GrB_Vector_build_UINT64(*ph_output , I, h , nz,GrB_MIN_UINT64));
+     308           3 :     LG_FREE_ALL;
+     309           3 :     return (GrB_SUCCESS) ;
+     310             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_BF_full1.c.func-sort-c.html b/experimental/algorithm/LAGraph_BF_full1.c.func-sort-c.html new file mode 100644 index 0000000000..5f946451a8 --- /dev/null +++ b/experimental/algorithm/LAGraph_BF_full1.c.func-sort-c.html @@ -0,0 +1,92 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_BF_full1.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_BF_full1.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:112112100.0 %
Date:2024-08-29 20:08:04Functions:55100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_BF_full15
BF1_LT4672
BF1_Identity9645
BF1_lMIN13716
BF1_PLUSrhs18388
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_BF_full1.c.func.html b/experimental/algorithm/LAGraph_BF_full1.c.func.html new file mode 100644 index 0000000000..9d48b228ca --- /dev/null +++ b/experimental/algorithm/LAGraph_BF_full1.c.func.html @@ -0,0 +1,92 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_BF_full1.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_BF_full1.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:112112100.0 %
Date:2024-08-29 20:08:04Functions:55100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
BF1_Identity9645
BF1_LT4672
BF1_PLUSrhs18388
BF1_lMIN13716
LAGraph_BF_full15
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_BF_full1.c.gcov.html b/experimental/algorithm/LAGraph_BF_full1.c.gcov.html new file mode 100644 index 0000000000..bca916d381 --- /dev/null +++ b/experimental/algorithm/LAGraph_BF_full1.c.gcov.html @@ -0,0 +1,445 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_BF_full1.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_BF_full1.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:112112100.0 %
Date:2024-08-29 20:08:04Functions:55100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_BF_full1.c: Bellman-Ford single-source shortest paths, returns tree,
+       3             : // while diagonal of input matrix A needs not to be explicit 0
+       4             : //------------------------------------------------------------------------------
+       5             : 
+       6             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       7             : // SPDX-License-Identifier: BSD-2-Clause
+       8             : //
+       9             : // For additional details (including references to third party source code and
+      10             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      11             : // Contributors.txt for a full list of contributors. Created, in part, with
+      12             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      13             : // DM22-0790
+      14             : 
+      15             : // Contributed by Jinhao Chen and Timothy A. Davis, Texas A&M University
+      16             : 
+      17             : //------------------------------------------------------------------------------
+      18             : 
+      19             : // LAGraph_BF_full1: Bellman-Ford single source shortest paths, returning both
+      20             : // the path lengths and the shortest-path tree.
+      21             : 
+      22             : // LAGraph_BF_full1 performs a Bellman-Ford to find out shortest path, parent
+      23             : // nodes along the path and the hops (number of edges) in the path from given
+      24             : // source vertex s in the range of [0, n) on graph given as matrix A with size
+      25             : // n*n. The sparse matrix A has entry A(i, j) if there is an edge from vertex i
+      26             : // to vertex j with weight w, then A(i, j) = w.
+      27             : 
+      28             : // LAGraph_BF_full1 returns GrB_SUCCESS if it succeeds.  In this case, there
+      29             : // are no negative-weight cycles in the graph, and d, pi, and h are returned.
+      30             : // The vector d has d(k) as the shortest distance from s to k. pi(k) = p+1,
+      31             : // where p is the parent node of k-th node in the shortest path. In particular,
+      32             : // pi(s) = 0. h(k) = hop(s, k), the number of edges from s to k in the shortest
+      33             : // path.
+      34             : 
+      35             : // If the graph has a negative-weight cycle, GrB_NO_VALUE is returned, and the
+      36             : // GrB_Vectors d(k), pi(k) and h(k)  (i.e., *pd_output, *ppi_output and
+      37             : // *ph_output respectively) will be NULL when negative-weight cycle detected.
+      38             : 
+      39             : // Otherwise, other errors such as GrB_OUT_OF_MEMORY, GrB_INVALID_OBJECT, and
+      40             : // so on, can be returned, if these errors are found by the underlying
+      41             : // GrB_* functions.
+      42             : 
+      43             : //------------------------------------------------------------------------------
+      44             : 
+      45             : #define LG_FREE_WORK                   \
+      46             : {                                      \
+      47             :     GrB_free(&d);                      \
+      48             :     GrB_free(&dmasked);                \
+      49             :     GrB_free(&dless);                  \
+      50             :     GrB_free(&Atmp);                   \
+      51             :     GrB_free(&BF_Tuple3);              \
+      52             :     GrB_free(&BF_lMIN_Tuple3);         \
+      53             :     GrB_free(&BF_PLUSrhs_Tuple3);      \
+      54             :     GrB_free(&BF_LT_Tuple3);           \
+      55             :     GrB_free(&BF_lMIN_Tuple3_Monoid);  \
+      56             :     GrB_free(&BF_lMIN_PLUSrhs_Tuple3); \
+      57             :     GrB_free(&BF_Identity_Tuple3 );    \
+      58             :     LAGraph_Free ((void**)&I, NULL);   \
+      59             :     LAGraph_Free ((void**)&J, NULL);   \
+      60             :     LAGraph_Free ((void**)&w, NULL);   \
+      61             :     LAGraph_Free ((void**)&W, NULL);   \
+      62             :     LAGraph_Free ((void**)&h, NULL);   \
+      63             :     LAGraph_Free ((void**)&pi, NULL);  \
+      64             : }
+      65             : 
+      66             : #define LG_FREE_ALL                    \
+      67             : {                                      \
+      68             :     LG_FREE_WORK ;                     \
+      69             :     GrB_free (pd_output);              \
+      70             :     GrB_free (ppi_output);             \
+      71             :     GrB_free (ph_output);              \
+      72             : }
+      73             : 
+      74             : #include <LAGraph.h>
+      75             : #include <LAGraphX.h>
+      76             : #include <LG_internal.h>  // from src/utility
+      77             : 
+      78             : 
+      79             : typedef void (*LAGraph_binary_function) (void *, const void *, const void *) ;
+      80             : 
+      81             : //------------------------------------------------------------------------------
+      82             : // data type for each entry of the adjacent matrix A and "distance" vector d;
+      83             : // <INFINITY,INFINITY,INFINITY> corresponds to nonexistence of a path, and
+      84             : // the value  <0, 0, NULL> corresponds to a path from a vertex to itself
+      85             : //------------------------------------------------------------------------------
+      86             : typedef struct
+      87             : {
+      88             :     double w;    // w  corresponds to a path weight.
+      89             :     GrB_Index h; // h  corresponds to a path size or number of hops.
+      90             :     GrB_Index pi;// pi corresponds to the penultimate vertex along a path.
+      91             :                  // vertex indexed as 1, 2, 3, ... , V, and pi = 0 (as nil)
+      92             :                  // for u=v, and pi = UINT64_MAX (as inf) for (u,v) not in E
+      93             : }
+      94             : BF1_Tuple3_struct;
+      95             : 
+      96             : //------------------------------------------------------------------------------
+      97             : // 2 binary functions, z=f(x,y), where Tuple3xTuple3 -> Tuple3
+      98             : //------------------------------------------------------------------------------
+      99       13716 : void BF1_lMIN
+     100             : (
+     101             :     BF1_Tuple3_struct *z,
+     102             :     const BF1_Tuple3_struct *x,
+     103             :     const BF1_Tuple3_struct *y
+     104             : )
+     105             : {
+     106       13716 :     if (x->w < y->w
+     107        4243 :         || (x->w == y->w && x->h < y->h)
+     108        4243 :         || (x->w == y->w && x->h == y->h && x->pi < y->pi))
+     109             :     {
+     110        9568 :         if (z != x) { *z = *x; }
+     111             :     }
+     112             :     else
+     113             :     {
+     114        4148 :         *z = *y;
+     115             :     }
+     116       13716 : }
+     117             : 
+     118       18388 : void BF1_PLUSrhs
+     119             : (
+     120             :     BF1_Tuple3_struct *z,
+     121             :     const BF1_Tuple3_struct *x,
+     122             :     const BF1_Tuple3_struct *y
+     123             : )
+     124             : {
+     125       18388 :     z->w = x->w + y->w;
+     126       18388 :     z->h = x->h + y->h;
+     127       18388 :     z->pi = (x->pi != UINT64_MAX && y->pi != 0) ?  y->pi : x->pi ;
+     128       18388 : }
+     129             : 
+     130        9645 : void BF1_Identity
+     131             : (
+     132             :     BF1_Tuple3_struct *z,
+     133             :     const BF1_Tuple3_struct *x
+     134             : )
+     135             : {
+     136        9645 :     *z = *x;
+     137        9645 : }
+     138             : 
+     139        4672 : void BF1_LT
+     140             : (
+     141             :     bool *z,
+     142             :     const BF1_Tuple3_struct *x,
+     143             :     const BF1_Tuple3_struct *y
+     144             : )
+     145             : {
+     146        9344 :     (*z) = (x->w < y->w
+     147         428 :         || (x->w == y->w && x->h < y->h)
+     148        5100 :         || (x->w == y->w && x->h == y->h && x->pi < y->pi)) ;
+     149        4672 : }
+     150             : 
+     151             : // Given a n-by-n adjacency matrix A and a source vertex s.
+     152             : // If there is no negative-weight cycle reachable from s, return the distances
+     153             : // of shortest paths from s and parents along the paths as vector d. Otherwise,
+     154             : // returns d=NULL if there is a negtive-weight cycle.
+     155             : // pd_output is pointer to a GrB_Vector, where the i-th entry is d(s,i), the
+     156             : //   sum of edges length in the shortest path
+     157             : // ppi_output is pointer to a GrB_Vector, where the i-th entry is pi(i), the
+     158             : //   parent of i-th vertex in the shortest path
+     159             : // ph_output is pointer to a GrB_Vector, where the i-th entry is h(s,i), the
+     160             : //   number of edges from s to i in the shortest path
+     161             : // A has weights on corresponding entries of edges
+     162             : // s is given index for source vertex
+     163           5 : GrB_Info LAGraph_BF_full1
+     164             : (
+     165             :     GrB_Vector *pd_output,      //the pointer to the vector of distance
+     166             :     GrB_Vector *ppi_output,     //the pointer to the vector of parent
+     167             :     GrB_Vector *ph_output,      //the pointer to the vector of hops
+     168             :     const GrB_Matrix A,         //matrix for the graph
+     169             :     const GrB_Index s           //given index of the source
+     170             : )
+     171             : {
+     172             :     GrB_Info info;
+     173           5 :     char *msg = NULL ;
+     174             :     // tmp vector to store distance vector after n (i.e., V) loops
+     175           5 :     GrB_Vector d = NULL, dmasked = NULL, dless = NULL;
+     176           5 :     GrB_Matrix Atmp = NULL;
+     177           5 :     GrB_Type BF_Tuple3 = NULL ;
+     178             : 
+     179           5 :     GrB_BinaryOp BF_lMIN_Tuple3 = NULL ;
+     180           5 :     GrB_BinaryOp BF_PLUSrhs_Tuple3 = NULL ;
+     181           5 :     GrB_UnaryOp BF_Identity_Tuple3 = NULL ;
+     182           5 :     GrB_BinaryOp BF_LT_Tuple3 = NULL ;
+     183             : 
+     184           5 :     GrB_Monoid BF_lMIN_Tuple3_Monoid = NULL ;
+     185           5 :     GrB_Semiring BF_lMIN_PLUSrhs_Tuple3 = NULL ;
+     186             : 
+     187             :     GrB_Index nrows, ncols, n, nz;  // n = # of row/col, nz = # of nnz in graph
+     188           5 :     GrB_Index *I = NULL, *J = NULL; // for col/row indices of entries from A
+     189           5 :     GrB_Index *h = NULL, *pi = NULL;
+     190           5 :     double *w = NULL;
+     191           5 :     BF1_Tuple3_struct *W = NULL;
+     192             : 
+     193           5 :     LG_ASSERT (A != NULL && pd_output != NULL &&
+     194             :         ppi_output != NULL && ph_output != NULL, GrB_NULL_POINTER) ;
+     195             : 
+     196           5 :     *pd_output  = NULL;
+     197           5 :     *ppi_output = NULL;
+     198           5 :     *ph_output  = NULL;
+     199           5 :     GRB_TRY (GrB_Matrix_nrows (&nrows, A)) ;
+     200           5 :     GRB_TRY (GrB_Matrix_ncols (&ncols, A)) ;
+     201           5 :     GRB_TRY (GrB_Matrix_nvals (&nz, A));
+     202           5 :     LG_ASSERT_MSG (nrows == ncols, -1002, "A must be square") ;
+     203           5 :     n = nrows;
+     204           5 :     LG_ASSERT_MSG (s < n, GrB_INVALID_INDEX, "invalid source node") ;
+     205             : 
+     206             :     //--------------------------------------------------------------------------
+     207             :     // create all GrB_Type GrB_BinaryOp GrB_Monoid and GrB_Semiring
+     208             :     //--------------------------------------------------------------------------
+     209             :     // GrB_Type
+     210           5 :     GRB_TRY (GrB_Type_new(&BF_Tuple3, sizeof(BF1_Tuple3_struct)));
+     211             : 
+     212             :     // GrB_BinaryOp
+     213           5 :     GRB_TRY (GrB_UnaryOp_new(&BF_Identity_Tuple3,
+     214             :         (void*) (&BF1_Identity), BF_Tuple3, BF_Tuple3));
+     215           5 :     GRB_TRY (GrB_BinaryOp_new(&BF_LT_Tuple3,
+     216             :         (LAGraph_binary_function) (&BF1_LT), GrB_BOOL, BF_Tuple3, BF_Tuple3));
+     217           5 :     GRB_TRY (GrB_BinaryOp_new(&BF_lMIN_Tuple3,
+     218             :         (LAGraph_binary_function) (&BF1_lMIN), BF_Tuple3, BF_Tuple3, BF_Tuple3));
+     219           5 :     GRB_TRY (GrB_BinaryOp_new(&BF_PLUSrhs_Tuple3,
+     220             :         (LAGraph_binary_function)(&BF1_PLUSrhs),
+     221             :         BF_Tuple3, BF_Tuple3, BF_Tuple3));
+     222             : 
+     223             :     // GrB_Monoid
+     224           5 :     BF1_Tuple3_struct BF_identity = (BF1_Tuple3_struct) { .w = INFINITY,
+     225             :         .h = UINT64_MAX, .pi = UINT64_MAX };
+     226           5 :     GRB_TRY (GrB_Monoid_new_UDT(&BF_lMIN_Tuple3_Monoid, BF_lMIN_Tuple3,
+     227             :         &BF_identity));
+     228             : 
+     229             :     //GrB_Semiring
+     230           5 :     GRB_TRY (GrB_Semiring_new(&BF_lMIN_PLUSrhs_Tuple3,
+     231             :         BF_lMIN_Tuple3_Monoid, BF_PLUSrhs_Tuple3));
+     232             : 
+     233             :     //--------------------------------------------------------------------------
+     234             :     // allocate arrays used for tuplets
+     235             :     //--------------------------------------------------------------------------
+     236             : 
+     237           5 :     LAGRAPH_TRY (LAGraph_Malloc ((void **) &I, nz, sizeof(GrB_Index), msg)) ;
+     238           5 :     LAGRAPH_TRY (LAGraph_Malloc ((void **) &J, nz, sizeof(GrB_Index), msg)) ;
+     239           5 :     LAGRAPH_TRY (LAGraph_Malloc ((void **) &w, nz, sizeof(double), msg)) ;
+     240           5 :     LAGRAPH_TRY (LAGraph_Malloc ((void **) &W, nz, sizeof(BF1_Tuple3_struct),
+     241             :         msg)) ;
+     242             : 
+     243             :     //--------------------------------------------------------------------------
+     244             :     // create matrix Atmp based on A, while its entries become BF_Tuple3 type
+     245             :     //--------------------------------------------------------------------------
+     246             : 
+     247           5 :     GRB_TRY (GrB_Matrix_extractTuples_FP64(I, J, w, &nz, A));
+     248             :     int nthreads, nthreads_outer, nthreads_inner ;
+     249           5 :     LG_TRY (LAGraph_GetNumThreads (&nthreads_outer, &nthreads_inner, msg)) ;
+     250           5 :     nthreads = nthreads_outer * nthreads_inner ;
+     251           5 :     printf ("nthreads %d\n", nthreads) ;
+     252             :     int64_t k;
+     253             :     #pragma omp parallel for num_threads(nthreads) schedule(static)
+     254         773 :     for (k = 0; k < nz; k++)
+     255             :     {
+     256         768 :         W[k] = (BF1_Tuple3_struct) { .w = w[k], .h = 1, .pi = I[k] + 1 };
+     257             :     }
+     258           5 :     GRB_TRY (GrB_Matrix_new(&Atmp, BF_Tuple3, n, n));
+     259           5 :     GRB_TRY (GrB_Matrix_build_UDT(Atmp, I, J, W, nz, BF_lMIN_Tuple3));
+     260           5 :     LAGraph_Free ((void**)&I, NULL);
+     261           5 :     LAGraph_Free ((void**)&J, NULL);
+     262           5 :     LAGraph_Free ((void**)&W, NULL);
+     263           5 :     LAGraph_Free ((void**)&w, NULL);
+     264             : 
+     265             :     //--------------------------------------------------------------------------
+     266             :     // create and initialize "distance" vector d, dmasked and dless
+     267             :     //--------------------------------------------------------------------------
+     268           5 :     GRB_TRY (GrB_Vector_new(&d, BF_Tuple3, n));
+     269             :     // make d dense
+     270           5 :     GRB_TRY (GrB_Vector_assign_UDT(d, NULL, NULL, (void*)&BF_identity,
+     271             :         GrB_ALL, n, NULL));
+     272             :     // initial distance from s to itself
+     273           5 :     BF1_Tuple3_struct d0 = (BF1_Tuple3_struct) { .w = 0, .h = 0, .pi = 0 };
+     274           5 :     GRB_TRY (GrB_Vector_setElement_UDT(d, &d0, s));
+     275             : 
+     276             :     // creat dmasked as a sparse vector with only one entry at s
+     277           5 :     GRB_TRY (GrB_Vector_new(&dmasked, BF_Tuple3, n));
+     278           5 :     GRB_TRY (GrB_Vector_setElement_UDT(dmasked, &d0, s));
+     279             : 
+     280             :     // create dless
+     281           5 :     GRB_TRY (GrB_Vector_new(&dless, GrB_BOOL, n));
+     282             : 
+     283             :     //--------------------------------------------------------------------------
+     284             :     // start the Bellman Ford process
+     285             :     //--------------------------------------------------------------------------
+     286           5 :     bool any_dless= true;      // if there is any newly found shortest path
+     287           5 :     int64_t iter = 0;          // number of iterations
+     288             : 
+     289             :     // terminate when no new path is found or more than V-1 loops
+     290          93 :     while (any_dless && iter < n - 1)
+     291             :     {
+     292             :         // execute semiring on d and A, and save the result to dtmp
+     293          88 :         GRB_TRY (GrB_vxm(dmasked, GrB_NULL, GrB_NULL,
+     294             :             BF_lMIN_PLUSrhs_Tuple3, dmasked, Atmp, GrB_NULL));
+     295             : 
+     296             :         // dless = d .< dtmp
+     297             :         //GRB_TRY (GrB_Vector_clear(dless));
+     298          88 :         GRB_TRY (GrB_eWiseMult(dless, NULL, NULL, BF_LT_Tuple3, dmasked, d,
+     299             :             NULL));
+     300             : 
+     301             :         // if there is no entry with smaller distance then all shortest paths
+     302             :         // are found
+     303          88 :         GRB_TRY (GrB_reduce (&any_dless, NULL, GrB_LOR_MONOID_BOOL, dless,
+     304             :             NULL)) ;
+     305          88 :         if(any_dless)
+     306             :         {
+     307             :             // update all entries with smaller distances
+     308          85 :             GRB_TRY (GrB_apply(d, dless, NULL, BF_Identity_Tuple3, dmasked, NULL));
+     309             : 
+     310             :             // only use entries that were just updated
+     311          85 :             GRB_TRY (GrB_Vector_clear(dmasked));
+     312          85 :             GRB_TRY (GrB_apply(dmasked, dless, NULL, BF_Identity_Tuple3, d, NULL));
+     313             :             //try:
+     314             :             //GRB_TRY (GrB_assign(dmasked, dless, NULL, d, GrB_ALL, n, GrB_DESC_R);
+     315             :         }
+     316          88 :         iter ++;
+     317             :     }
+     318             : 
+     319             :     // check for negative-weight cycle only when there was a new path in the
+     320             :     // last loop, otherwise, there can't be a negative-weight cycle.
+     321           5 :     if (any_dless)
+     322             :     {
+     323             :         // execute semiring again to check for negative-weight cycle
+     324           2 :         GRB_TRY (GrB_vxm(dmasked, GrB_NULL, GrB_NULL,
+     325             :             BF_lMIN_PLUSrhs_Tuple3, dmasked, Atmp, GrB_NULL));
+     326             : 
+     327             :         // dless = d .< dtmp
+     328             :         //GRB_TRY (GrB_Vector_clear(dless));
+     329           2 :         GRB_TRY (GrB_eWiseMult(dless, NULL, NULL, BF_LT_Tuple3, dmasked, d, NULL));
+     330             : 
+     331             :         // if there is no entry with smaller distance then all shortest paths
+     332             :         // are found
+     333           2 :         GRB_TRY (GrB_reduce (&any_dless, NULL, GrB_LOR_MONOID_BOOL, dless, NULL)) ;
+     334           2 :         if(any_dless)
+     335             :         {
+     336             :             // printf("A negative-weight cycle found. \n");
+     337           2 :             LG_FREE_ALL;
+     338           2 :             return (GrB_NO_VALUE) ;
+     339             :         }
+     340             :     }
+     341             : 
+     342             :     //--------------------------------------------------------------------------
+     343             :     // extract tuple from "distance" vector d and create GrB_Vectors for output
+     344             :     //--------------------------------------------------------------------------
+     345             : 
+     346           3 :     LAGRAPH_TRY (LAGraph_Malloc ((void **) &I, n, sizeof(GrB_Index), msg)) ;
+     347           3 :     LAGRAPH_TRY (LAGraph_Malloc ((void **) &W, n, sizeof(BF1_Tuple3_struct),
+     348             :         msg)) ;
+     349           3 :     LAGRAPH_TRY (LAGraph_Malloc ((void **) &w, n, sizeof(double), msg)) ;
+     350           3 :     LAGRAPH_TRY (LAGraph_Malloc ((void **) &h, n, sizeof(GrB_Index), msg)) ;
+     351           3 :     LAGRAPH_TRY (LAGraph_Malloc ((void **) &pi, n, sizeof(GrB_Index), msg)) ;
+     352             : 
+     353           3 :     GRB_TRY (GrB_Vector_extractTuples_UDT (I, (void *) W, &n, d));
+     354             : 
+     355         111 :     for (k = 0; k < n; k++)
+     356             :     {
+     357         108 :         w [k] = W[k].w ;
+     358         108 :         h [k] = W[k].h ;
+     359         108 :         pi[k] = W[k].pi;
+     360             :     }
+     361           3 :     GRB_TRY (GrB_Vector_new(pd_output,  GrB_FP64,   n));
+     362           3 :     GRB_TRY (GrB_Vector_new(ppi_output, GrB_UINT64, n));
+     363           3 :     GRB_TRY (GrB_Vector_new(ph_output,  GrB_UINT64, n));
+     364           3 :     GRB_TRY (GrB_Vector_build (*pd_output , I, w , n, GrB_MIN_FP64  ));
+     365           3 :     GRB_TRY (GrB_Vector_build (*ppi_output, I, pi, n, GrB_MIN_UINT64));
+     366           3 :     GRB_TRY (GrB_Vector_build (*ph_output , I, h , n, GrB_MIN_UINT64));
+     367           3 :     LG_FREE_WORK;
+     368           3 :     return (GrB_SUCCESS) ;
+     369             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_BF_full1a.c.func-sort-c.html b/experimental/algorithm/LAGraph_BF_full1a.c.func-sort-c.html new file mode 100644 index 0000000000..58e712513d --- /dev/null +++ b/experimental/algorithm/LAGraph_BF_full1a.c.func-sort-c.html @@ -0,0 +1,88 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_BF_full1a.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_BF_full1a.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:100100100.0 %
Date:2024-08-29 20:08:04Functions:44100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_BF_full1a5
BF_LT34672
BF_lMIN313716
BF_PLUSrhs318388
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_BF_full1a.c.func.html b/experimental/algorithm/LAGraph_BF_full1a.c.func.html new file mode 100644 index 0000000000..d3875c0545 --- /dev/null +++ b/experimental/algorithm/LAGraph_BF_full1a.c.func.html @@ -0,0 +1,88 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_BF_full1a.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_BF_full1a.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:100100100.0 %
Date:2024-08-29 20:08:04Functions:44100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
BF_LT34672
BF_PLUSrhs318388
BF_lMIN313716
LAGraph_BF_full1a5
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_BF_full1a.c.gcov.html b/experimental/algorithm/LAGraph_BF_full1a.c.gcov.html new file mode 100644 index 0000000000..7e25849b92 --- /dev/null +++ b/experimental/algorithm/LAGraph_BF_full1a.c.gcov.html @@ -0,0 +1,467 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_BF_full1a.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_BF_full1a.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:100100100.0 %
Date:2024-08-29 20:08:04Functions:44100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_BF_full1a.c: Bellman-Ford single-source shortest paths, returns tree,
+       3             : // while diagonal of input matrix A needs not to be explicit 0
+       4             : //------------------------------------------------------------------------------
+       5             : 
+       6             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       7             : // SPDX-License-Identifier: BSD-2-Clause
+       8             : //
+       9             : // For additional details (including references to third party source code and
+      10             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      11             : // Contributors.txt for a full list of contributors. Created, in part, with
+      12             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      13             : // DM22-0790
+      14             : 
+      15             : // Contributed by Jinhao Chen and Timothy A. Davis, Texas A&M University
+      16             : 
+      17             : //------------------------------------------------------------------------------
+      18             : 
+      19             : // This is the fastest variant that computes both the parent & the path length.
+      20             : 
+      21             : // LAGraph_BF_full1a: Bellman-Ford single source shortest paths, returning both
+      22             : // the path lengths and the shortest-path tree.
+      23             : 
+      24             : // LAGraph_BF_full performs a Bellman-Ford to find out shortest path, parent
+      25             : // nodes along the path and the hops (number of edges) in the path from given
+      26             : // source vertex s in the range of [0, n) on graph given as matrix A with size
+      27             : // n*n. The sparse matrix A has entry A(i, j) if there is an edge from vertex i
+      28             : // to vertex j with weight w, then A(i, j) = w.
+      29             : 
+      30             : // LAGraph_BF_full1a returns GrB_SUCCESS if it succeeds.  In this case, there
+      31             : // are no negative-weight cycles in the graph, and d, pi, and h are returned.
+      32             : // The vector d has d(k) as the shortest distance from s to k. pi(k) = p+1,
+      33             : // where p is the parent node of k-th node in the shortest path. In particular,
+      34             : // pi(s) = 0. h(k) = hop(s, k), the number of edges from s to k in the shortest
+      35             : // path.
+      36             : 
+      37             : // If the graph has a negative-weight cycle, GrB_NO_VALUE is returned, and the
+      38             : // GrB_Vectors d(k), pi(k) and h(k)  (i.e., *pd_output, *ppi_output and
+      39             : // *ph_output respectively) will be NULL when negative-weight cycle detected.
+      40             : 
+      41             : // Otherwise, other errors such as GrB_OUT_OF_MEMORY, GrB_INVALID_OBJECT, and
+      42             : // so on, can be returned, if these errors are found by the underlying
+      43             : // GrB_* functions.
+      44             : 
+      45             : //------------------------------------------------------------------------------
+      46             : 
+      47             : #define LG_FREE_WORK                   \
+      48             : {                                      \
+      49             :     GrB_free(&d);                      \
+      50             :     GrB_free(&dmasked);                \
+      51             :     GrB_free(&dless);                  \
+      52             :     GrB_free(&Atmp);                   \
+      53             :     GrB_free(&BF_Tuple3);              \
+      54             :     GrB_free(&BF_lMIN_Tuple3);         \
+      55             :     GrB_free(&BF_PLUSrhs_Tuple3);      \
+      56             :     GrB_free(&BF_LT_Tuple3);           \
+      57             :     GrB_free(&BF_lMIN_Tuple3_Monoid);  \
+      58             :     GrB_free(&BF_lMIN_PLUSrhs_Tuple3); \
+      59             :     LAGraph_Free ((void**)&I, NULL);   \
+      60             :     LAGraph_Free ((void**)&J, NULL);   \
+      61             :     LAGraph_Free ((void**)&w, NULL);   \
+      62             :     LAGraph_Free ((void**)&W, NULL);   \
+      63             :     LAGraph_Free ((void**)&h, NULL);   \
+      64             :     LAGraph_Free ((void**)&pi, NULL);  \
+      65             : }
+      66             : 
+      67             : #define LG_FREE_ALL                    \
+      68             : {                                      \
+      69             :     LG_FREE_WORK ;                     \
+      70             :     GrB_free (pd_output);              \
+      71             :     GrB_free (ppi_output);             \
+      72             :     GrB_free (ph_output);              \
+      73             : }
+      74             : 
+      75             : #include <LAGraph.h>
+      76             : #include <LAGraphX.h>
+      77             : #include <LG_internal.h>  // from src/utility
+      78             : 
+      79             : typedef void (*LAGraph_binary_function) (void *, const void *, const void *) ;
+      80             : 
+      81             : //------------------------------------------------------------------------------
+      82             : // data type for each entry of the adjacent matrix A and "distance" vector d;
+      83             : // <INFINITY,INFINITY,INFINITY> corresponds to nonexistence of a path, and
+      84             : // the value  <0, 0, NULL> corresponds to a path from a vertex to itself
+      85             : //------------------------------------------------------------------------------
+      86             : 
+      87             : typedef struct
+      88             : {
+      89             :     double w;    // w  corresponds to a path weight.
+      90             :     GrB_Index h; // h  corresponds to a path size or number of hops.
+      91             :     GrB_Index pi;// pi corresponds to the penultimate vertex along a path.
+      92             :                  // vertex indexed as 1, 2, 3, ... , V, and pi = 0 (as nil)
+      93             :                  // for u=v, and pi = UINT64_MAX (as inf) for (u,v) not in E
+      94             : }
+      95             : BF_Tuple3_struct;
+      96             : 
+      97             : //------------------------------------------------------------------------------
+      98             : // binary functions, z=f(x,y), where Tuple3xTuple3 -> Tuple3
+      99             : //------------------------------------------------------------------------------
+     100             : 
+     101       13716 : void BF_lMIN3
+     102             : (
+     103             :     BF_Tuple3_struct *z,
+     104             :     const BF_Tuple3_struct *x,
+     105             :     const BF_Tuple3_struct *y
+     106             : )
+     107             : {
+     108       13716 :     if (x->w < y->w
+     109        4243 :         || (x->w == y->w && x->h < y->h)
+     110        4243 :         || (x->w == y->w && x->h == y->h && x->pi < y->pi))
+     111             :     {
+     112        9568 :         if (z != x) { *z = *x; }
+     113             :     }
+     114             :     else
+     115             :     {
+     116        4148 :         *z = *y;
+     117             :     }
+     118       13716 : }
+     119             : 
+     120       18388 : void BF_PLUSrhs3
+     121             : (
+     122             :     BF_Tuple3_struct *z,
+     123             :     const BF_Tuple3_struct *x,
+     124             :     const BF_Tuple3_struct *y
+     125             : )
+     126             : {
+     127       18388 :     z->w = x->w + y->w ;
+     128       18388 :     z->h = x->h + y->h ;
+     129       18388 :     z->pi = (x->pi != UINT64_MAX && y->pi != 0) ?  y->pi : x->pi ;
+     130       18388 : }
+     131             : 
+     132        4672 : void BF_LT3
+     133             : (
+     134             :     bool *z,
+     135             :     const BF_Tuple3_struct *x,
+     136             :     const BF_Tuple3_struct *y
+     137             : )
+     138             : {
+     139        9344 :     (*z) = (x->w < y->w
+     140         428 :         || (x->w == y->w && x->h < y->h)
+     141        5100 :         || (x->w == y->w && x->h == y->h && x->pi < y->pi)) ;
+     142        4672 : }
+     143             : 
+     144             : // Given a n-by-n adjacency matrix A and a source vertex s.
+     145             : // If there is no negative-weight cycle reachable from s, return the distances
+     146             : // of shortest paths from s and parents along the paths as vector d. Otherwise,
+     147             : // returns d=NULL if there is a negtive-weight cycle.
+     148             : // pd_output is pointer to a GrB_Vector, where the i-th entry is d(s,i), the
+     149             : //   sum of edges length in the shortest path
+     150             : // ppi_output is pointer to a GrB_Vector, where the i-th entry is pi(i), the
+     151             : //   parent of i-th vertex in the shortest path
+     152             : // ph_output is pointer to a GrB_Vector, where the i-th entry is h(s,i), the
+     153             : //   number of edges from s to i in the shortest path
+     154             : // A has weights on corresponding entries of edges
+     155             : // s is given index for source vertex
+     156           5 : GrB_Info LAGraph_BF_full1a
+     157             : (
+     158             :     GrB_Vector *pd_output,      //the pointer to the vector of distance
+     159             :     GrB_Vector *ppi_output,     //the pointer to the vector of parent
+     160             :     GrB_Vector *ph_output,      //the pointer to the vector of hops
+     161             :     const GrB_Matrix A,         //matrix for the graph
+     162             :     const GrB_Index s           //given index of the source
+     163             : )
+     164             : {
+     165             :     GrB_Info info;
+     166           5 :     char *msg = NULL ;
+     167             :     // tmp vector to store distance vector after n (i.e., V) loops
+     168           5 :     GrB_Vector d = NULL, dmasked = NULL, dless = NULL;
+     169           5 :     GrB_Matrix Atmp = NULL;
+     170             :     GrB_Type BF_Tuple3;
+     171             : 
+     172             :     GrB_BinaryOp BF_lMIN_Tuple3;
+     173             :     GrB_BinaryOp BF_PLUSrhs_Tuple3;
+     174             :     GrB_BinaryOp BF_LT_Tuple3;
+     175             : 
+     176             :     GrB_Monoid BF_lMIN_Tuple3_Monoid;
+     177             :     GrB_Semiring BF_lMIN_PLUSrhs_Tuple3;
+     178             : 
+     179             :     GrB_Index nrows, ncols, n, nz;  // n = # of row/col, nz = # of nnz in graph
+     180           5 :     GrB_Index *I = NULL, *J = NULL; // for col/row indices of entries from A
+     181           5 :     GrB_Index *h = NULL, *pi = NULL;
+     182           5 :     double *w = NULL;
+     183           5 :     BF_Tuple3_struct *W = NULL;
+     184             : 
+     185           5 :     if (pd_output  != NULL) *pd_output  = NULL;
+     186           5 :     if (ppi_output != NULL) *ppi_output = NULL;
+     187           5 :     if (ph_output  != NULL) *ph_output  = NULL;
+     188             : 
+     189           5 :     LG_ASSERT (A != NULL && pd_output != NULL &&
+     190             :         ppi_output != NULL && ph_output != NULL, GrB_NULL_POINTER) ;
+     191             : 
+     192           5 :     GRB_TRY (GrB_Matrix_nrows (&nrows, A)) ;
+     193           5 :     GRB_TRY (GrB_Matrix_ncols (&ncols, A)) ;
+     194           5 :     GRB_TRY (GrB_Matrix_nvals (&nz, A));
+     195           5 :     LG_ASSERT_MSG (nrows == ncols, -1002, "A must be square") ;
+     196           5 :     n = nrows;
+     197           5 :     LG_ASSERT_MSG (s < n, GrB_INVALID_INDEX, "invalid source node") ;
+     198             : 
+     199             :     //--------------------------------------------------------------------------
+     200             :     // create all GrB_Type GrB_BinaryOp GrB_Monoid and GrB_Semiring
+     201             :     //--------------------------------------------------------------------------
+     202             :     // GrB_Type
+     203           5 :     GRB_TRY (GrB_Type_new(&BF_Tuple3, sizeof(BF_Tuple3_struct)));
+     204             : 
+     205             :     // GrB_BinaryOp
+     206           5 :     GRB_TRY (GrB_BinaryOp_new(&BF_LT_Tuple3,
+     207             :         (LAGraph_binary_function) (&BF_LT3), GrB_BOOL, BF_Tuple3, BF_Tuple3));
+     208           5 :     GRB_TRY (GrB_BinaryOp_new(&BF_lMIN_Tuple3,
+     209             :         (LAGraph_binary_function) (&BF_lMIN3), BF_Tuple3, BF_Tuple3,BF_Tuple3));
+     210           5 :     GRB_TRY (GrB_BinaryOp_new(&BF_PLUSrhs_Tuple3,
+     211             :         (LAGraph_binary_function)(&BF_PLUSrhs3),
+     212             :         BF_Tuple3, BF_Tuple3, BF_Tuple3));
+     213             : 
+     214             :     // GrB_Monoid
+     215           5 :     BF_Tuple3_struct BF_identity = (BF_Tuple3_struct) { .w = INFINITY,
+     216             :         .h = UINT64_MAX, .pi = UINT64_MAX };
+     217           5 :     GRB_TRY (GrB_Monoid_new_UDT(&BF_lMIN_Tuple3_Monoid, BF_lMIN_Tuple3,
+     218             :         &BF_identity));
+     219             : 
+     220             :     //GrB_Semiring
+     221           5 :     GRB_TRY (GrB_Semiring_new(&BF_lMIN_PLUSrhs_Tuple3,
+     222             :         BF_lMIN_Tuple3_Monoid, BF_PLUSrhs_Tuple3));
+     223             : 
+     224             :     //--------------------------------------------------------------------------
+     225             :     // allocate arrays used for tuplets
+     226             :     //--------------------------------------------------------------------------
+     227             : #if 1
+     228           5 :     LAGRAPH_TRY (LAGraph_Malloc ((void **) &I, nz, sizeof(GrB_Index), msg)) ;
+     229           5 :     LAGRAPH_TRY (LAGraph_Malloc ((void **) &J, nz, sizeof(GrB_Index), msg)) ;
+     230           5 :     LAGRAPH_TRY (LAGraph_Malloc ((void **) &w, nz, sizeof(double), msg)) ;
+     231           5 :     LAGRAPH_TRY (LAGraph_Malloc ((void **) &W, nz, sizeof(BF_Tuple3_struct),
+     232             :         msg)) ;
+     233             : 
+     234             :     //--------------------------------------------------------------------------
+     235             :     // create matrix Atmp based on A, while its entries become BF_Tuple3 type
+     236             :     //--------------------------------------------------------------------------
+     237             : 
+     238           5 :     GRB_TRY (GrB_Matrix_extractTuples_FP64(I, J, w, &nz, A));
+     239             :     int nthreads, nthreads_outer, nthreads_inner ;
+     240           5 :     LG_TRY (LAGraph_GetNumThreads (&nthreads_outer, &nthreads_inner, msg)) ;
+     241           5 :     nthreads = nthreads_outer * nthreads_inner ;
+     242           5 :     printf ("nthreads %d\n", nthreads) ;
+     243             :     int64_t k;
+     244             :     #pragma omp parallel for num_threads(nthreads) schedule(static)
+     245         773 :     for (k = 0; k < nz; k++)
+     246             :     {
+     247         768 :         W[k] = (BF_Tuple3_struct) { .w = w[k], .h = 1, .pi = I[k] + 1 };
+     248             :     }
+     249           5 :     GRB_TRY (GrB_Matrix_new(&Atmp, BF_Tuple3, n, n));
+     250           5 :     GRB_TRY (GrB_Matrix_build_UDT(Atmp, I, J, W, nz, BF_lMIN_Tuple3));
+     251           5 :     LAGraph_Free ((void**)&I, NULL);
+     252           5 :     LAGraph_Free ((void**)&J, NULL);
+     253           5 :     LAGraph_Free ((void**)&W, NULL);
+     254           5 :     LAGraph_Free ((void**)&w, NULL);
+     255             : 
+     256             : #else
+     257             : 
+     258             :     todo: GraphBLAS could use a new kind of unary operator, not z=f(x), but
+     259             : 
+     260             :     [z,flag] = f (aij, i, j, k, nrows, ncols, nvals, etc, ...)
+     261             :     flag: keep or discard.  Combines GrB_apply and GxB_select.
+     262             : 
+     263             :     builtins:
+     264             :         f(...) =
+     265             :             i, bool is true
+     266             :             j, bool is true
+     267             :             i+j*nrows, etc.
+     268             :             k
+     269             :             tril, triu (like GxB_select): return aij, and true/false boolean
+     270             : 
+     271             :         z=f(x,i).  x: double, z:tuple3, i:GrB_Index with the row index of x
+     272             :         // z = (BF_Tuple3_struct) { .w = x, .h = 1, .pi = i + 1 };
+     273             : 
+     274             :     GrB_apply (Atmp, op, A, ...)
+     275             : 
+     276             :     in the BFS, this is used:
+     277             :         op:  z = f ( .... ) = i
+     278             :         to replace x(i) with i
+     279             : 
+     280             : #endif
+     281             : 
+     282             :     //--------------------------------------------------------------------------
+     283             :     // create and initialize "distance" vector d, dmasked and dless
+     284             :     //--------------------------------------------------------------------------
+     285           5 :     GRB_TRY (GrB_Vector_new(&d, BF_Tuple3, n));
+     286             :     // make d dense
+     287           5 :     GRB_TRY (GrB_Vector_assign_UDT(d, NULL, NULL, (void*)&BF_identity,
+     288             :         GrB_ALL, n, NULL));
+     289             :     // initial distance from s to itself
+     290           5 :     BF_Tuple3_struct d0 = (BF_Tuple3_struct) { .w = 0, .h = 0, .pi = 0 };
+     291           5 :     GRB_TRY (GrB_Vector_setElement_UDT(d, &d0, s));
+     292             : 
+     293             :     // creat dmasked as a sparse vector with only one entry at s
+     294           5 :     GRB_TRY (GrB_Vector_new(&dmasked, BF_Tuple3, n));
+     295           5 :     GRB_TRY (GrB_Vector_setElement_UDT(dmasked, &d0, s));
+     296             : 
+     297             :     // create dless
+     298           5 :     GRB_TRY (GrB_Vector_new(&dless, GrB_BOOL, n));
+     299             : 
+     300             :     //--------------------------------------------------------------------------
+     301             :     // start the Bellman Ford process
+     302             :     //--------------------------------------------------------------------------
+     303           5 :     bool any_dless= true;      // if there is any newly found shortest path
+     304           5 :     int64_t iter = 0;          // number of iterations
+     305             : 
+     306             :     // terminate when no new path is found or more than V-1 loops
+     307          93 :     while (any_dless && iter < n - 1)
+     308             :     {
+     309             :         // execute semiring on dmasked and A, and save the result to dmasked
+     310          88 :         GRB_TRY (GrB_vxm(dmasked, GrB_NULL, GrB_NULL,
+     311             :             BF_lMIN_PLUSrhs_Tuple3, dmasked, Atmp, GrB_NULL));
+     312             : 
+     313             :         // dless = d .< dtmp
+     314          88 :         GRB_TRY (GrB_eWiseMult(dless, NULL, NULL, BF_LT_Tuple3, dmasked, d,
+     315             :             NULL));
+     316             : 
+     317             :         // if there is no entry with smaller distance then all shortest paths
+     318             :         // are found
+     319          88 :         GRB_TRY (GrB_reduce (&any_dless, NULL, GrB_LOR_MONOID_BOOL, dless,
+     320             :             NULL)) ;
+     321          88 :         if(any_dless)
+     322             :         {
+     323             :             // update all entries with smaller distances
+     324             :             //GRB_TRY (GrB_apply(d, dless, NULL, BF_Identity_Tuple3,
+     325             :             //    dmasked, NULL));
+     326          85 :             GRB_TRY (GrB_assign(d, dless, NULL, dmasked, GrB_ALL, n, NULL));
+     327             : 
+     328             :             // only use entries that were just updated
+     329             :             //GRB_TRY (GrB_Vector_clear(dmasked));
+     330             :             //GRB_TRY (GrB_apply(dmasked, dless, NULL, BF_Identity_Tuple3,
+     331             :             //    d, NULL));
+     332             :             //try:
+     333          85 :             GRB_TRY (GrB_assign(dmasked, dless, NULL, d, GrB_ALL, n, GrB_DESC_R));
+     334             :         }
+     335          88 :         iter ++;
+     336             :     }
+     337             : 
+     338             :     // check for negative-weight cycle only when there was a new path in the
+     339             :     // last loop, otherwise, there can't be a negative-weight cycle.
+     340           5 :     if (any_dless)
+     341             :     {
+     342             :         // execute semiring again to check for negative-weight cycle
+     343           2 :         GRB_TRY (GrB_vxm(dmasked, GrB_NULL, GrB_NULL,
+     344             :             BF_lMIN_PLUSrhs_Tuple3, dmasked, Atmp, GrB_NULL));
+     345             : 
+     346             :         // dless = d .< dtmp
+     347           2 :         GRB_TRY (GrB_eWiseMult(dless, NULL, NULL, BF_LT_Tuple3, dmasked, d,
+     348             :             NULL));
+     349             : 
+     350             :         // if there is no entry with smaller distance then all shortest paths
+     351             :         // are found
+     352           2 :         GRB_TRY (GrB_reduce (&any_dless, NULL, GrB_LOR_MONOID_BOOL, dless,
+     353             :             NULL)) ;
+     354           2 :         if(any_dless)
+     355             :         {
+     356             :             // printf("A negative-weight cycle found. \n");
+     357           2 :             LG_FREE_ALL;
+     358           2 :             return (GrB_NO_VALUE) ;
+     359             :         }
+     360             :     }
+     361             : 
+     362             :     //--------------------------------------------------------------------------
+     363             :     // extract tuple from "distance" vector d and create GrB_Vectors for output
+     364             :     //--------------------------------------------------------------------------
+     365             : 
+     366           3 :     LAGRAPH_TRY (LAGraph_Malloc ((void **) &I, n, sizeof(GrB_Index), msg)) ;
+     367           3 :     LAGRAPH_TRY (LAGraph_Malloc ((void **) &W, n, sizeof(BF_Tuple3_struct),
+     368             :         msg)) ;
+     369           3 :     LAGRAPH_TRY (LAGraph_Malloc ((void **) &w, n, sizeof(double), msg)) ;
+     370           3 :     LAGRAPH_TRY (LAGraph_Malloc ((void **) &h, n, sizeof(GrB_Index), msg)) ;
+     371           3 :     LAGRAPH_TRY (LAGraph_Malloc ((void **) &pi, n, sizeof(GrB_Index), msg)) ;
+     372             : 
+     373             :     // todo: create 3 unary ops, and use GrB_apply?
+     374             : 
+     375           3 :     GRB_TRY (GrB_Vector_extractTuples_UDT (I, (void *) W, &n, d));
+     376             : 
+     377         111 :     for (k = 0; k < n; k++)
+     378             :     {
+     379         108 :         w [k] = W[k].w ;
+     380         108 :         h [k] = W[k].h ;
+     381         108 :         pi[k] = W[k].pi;
+     382             :     }
+     383           3 :     GRB_TRY (GrB_Vector_new(pd_output,  GrB_FP64,   n));
+     384           3 :     GRB_TRY (GrB_Vector_new(ppi_output, GrB_UINT64, n));
+     385           3 :     GRB_TRY (GrB_Vector_new(ph_output,  GrB_UINT64, n));
+     386           3 :     GRB_TRY (GrB_Vector_build (*pd_output , I, w , n, GrB_MIN_FP64  ));
+     387           3 :     GRB_TRY (GrB_Vector_build (*ppi_output, I, pi, n, GrB_MIN_UINT64));
+     388           3 :     GRB_TRY (GrB_Vector_build (*ph_output , I, h , n, GrB_MIN_UINT64));
+     389           3 :     LG_FREE_WORK;
+     390           3 :     return (GrB_SUCCESS) ;
+     391             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_BF_full2.c.func-sort-c.html b/experimental/algorithm/LAGraph_BF_full2.c.func-sort-c.html new file mode 100644 index 0000000000..ad5bfe7206 --- /dev/null +++ b/experimental/algorithm/LAGraph_BF_full2.c.func-sort-c.html @@ -0,0 +1,88 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_BF_full2.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_BF_full2.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:100100100.0 %
Date:2024-08-29 20:08:04Functions:44100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_BF_full25
BF2_EQ4424
BF2_lMIN220299
BF2_PLUSrhs220476
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_BF_full2.c.func.html b/experimental/algorithm/LAGraph_BF_full2.c.func.html new file mode 100644 index 0000000000..a70c792a49 --- /dev/null +++ b/experimental/algorithm/LAGraph_BF_full2.c.func.html @@ -0,0 +1,88 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_BF_full2.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_BF_full2.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:100100100.0 %
Date:2024-08-29 20:08:04Functions:44100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
BF2_EQ4424
BF2_PLUSrhs220476
BF2_lMIN220299
LAGraph_BF_full25
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_BF_full2.c.gcov.html b/experimental/algorithm/LAGraph_BF_full2.c.gcov.html new file mode 100644 index 0000000000..7c7c8a2476 --- /dev/null +++ b/experimental/algorithm/LAGraph_BF_full2.c.gcov.html @@ -0,0 +1,425 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_BF_full2.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_BF_full2.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:100100100.0 %
Date:2024-08-29 20:08:04Functions:44100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_BF_full2.c: Bellman-Ford single-source shortest paths, returns tree,
+       3             : // while diagonal of input matrix A needs not to be explicit 0, using the
+       4             : // frontier idea from Roi Lipman
+       5             : //------------------------------------------------------------------------------
+       6             : 
+       7             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       8             : // SPDX-License-Identifier: BSD-2-Clause
+       9             : //
+      10             : // For additional details (including references to third party source code and
+      11             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      12             : // Contributors.txt for a full list of contributors. Created, in part, with
+      13             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      14             : // DM22-0790
+      15             : 
+      16             : // Contributed by Jinhao Chen and Timothy A. Davis, Texas A&M University
+      17             : 
+      18             : //------------------------------------------------------------------------------
+      19             : 
+      20             : // LAGraph_BF_full2: Bellman-Ford single source shortest paths, returning both
+      21             : // the path lengths and the shortest-path tree.
+      22             : 
+      23             : // LAGraph_BF_full2 performs a Bellman-Ford to find out shortest path, parent
+      24             : // nodes along the path and the hops (number of edges) in the path from given
+      25             : // source vertex s in the range of [0, n) on graph given as matrix A with size
+      26             : // n*n. The sparse matrix A has entry A(i, j) if there is an edge from vertex i
+      27             : // to vertex j with weight w, then A(i, j) = w.
+      28             : 
+      29             : // LAGraph_BF_full2 returns GrB_SUCCESS if it succeeds.  In this case, there
+      30             : // are no negative-weight cycles in the graph, and d, pi, and h are returned.
+      31             : // The vector d has d(k) as the shortest distance from s to k. pi(k) = p+1,
+      32             : // where p is the parent node of k-th node in the shortest path. In particular,
+      33             : // pi(s) = 0. h(k) = hop(s, k), the number of edges from s to k in the shortest
+      34             : // path.
+      35             : 
+      36             : // If the graph has a negative-weight cycle, GrB_NO_VALUE is returned, and the
+      37             : // GrB_Vectors d(k), pi(k) and h(k)  (i.e., *pd_output, *ppi_output and
+      38             : // *ph_output respectively) will be NULL when negative-weight cycle detected.
+      39             : 
+      40             : // Otherwise, other errors such as GrB_OUT_OF_MEMORY, GrB_INVALID_OBJECT, and
+      41             : // so on, can be returned, if these errors are found by the underlying
+      42             : // GrB_* functions.
+      43             : 
+      44             : //------------------------------------------------------------------------------
+      45             : 
+      46             : #define LG_FREE_WORK                   \
+      47             : {                                      \
+      48             :     GrB_free(&d);                      \
+      49             :     GrB_free(&dtmp);                   \
+      50             :     GrB_free(&dfrontier);              \
+      51             :     GrB_free(&Atmp);                   \
+      52             :     GrB_free(&BF_Tuple3);              \
+      53             :     GrB_free(&BF_lMIN_Tuple3);         \
+      54             :     GrB_free(&BF_PLUSrhs_Tuple3);      \
+      55             :     GrB_free(&BF_EQ_Tuple3);           \
+      56             :     GrB_free(&BF_lMIN_Tuple3_Monoid);  \
+      57             :     GrB_free(&BF_lMIN_PLUSrhs_Tuple3); \
+      58             :     LAGraph_Free ((void**)&I, NULL);   \
+      59             :     LAGraph_Free ((void**)&J, NULL);   \
+      60             :     LAGraph_Free ((void**)&w, NULL);   \
+      61             :     LAGraph_Free ((void**)&W, NULL);   \
+      62             :     LAGraph_Free ((void**)&h, NULL);   \
+      63             :     LAGraph_Free ((void**)&pi, NULL);  \
+      64             : }
+      65             : 
+      66             : #define LG_FREE_ALL                    \
+      67             : {                                      \
+      68             :     LG_FREE_WORK ;                     \
+      69             :     GrB_free (pd_output);              \
+      70             :     GrB_free (ppi_output);             \
+      71             :     GrB_free (ph_output);              \
+      72             : }
+      73             : 
+      74             : #include <LAGraph.h>
+      75             : #include <LAGraphX.h>
+      76             : #include <LG_internal.h>  // from src/utility
+      77             : 
+      78             : 
+      79             : typedef void (*LAGraph_binary_function) (void *, const void *, const void *) ;
+      80             : 
+      81             : //------------------------------------------------------------------------------
+      82             : // data type for each entry of the adjacent matrix A and "distance" vector d;
+      83             : // <INFINITY,INFINITY,INFINITY> corresponds to nonexistence of a path, and
+      84             : // the value  <0, 0, NULL> corresponds to a path from a vertex to itself
+      85             : //------------------------------------------------------------------------------
+      86             : typedef struct
+      87             : {
+      88             :     double w;    // w  corresponds to a path weight.
+      89             :     GrB_Index h; // h  corresponds to a path size or number of hops.
+      90             :     GrB_Index pi;// pi corresponds to the penultimate vertex along a path.
+      91             :                  // vertex indexed as 1, 2, 3, ... , V, and pi = 0 (as nil)
+      92             :                  // for u=v, and pi = UINT64_MAX (as inf) for (u,v) not in E
+      93             : }
+      94             : BF2_Tuple3_struct;
+      95             : 
+      96             : //------------------------------------------------------------------------------
+      97             : // binary functions, z=f(x,y), where Tuple3xTuple3 -> Tuple3
+      98             : //------------------------------------------------------------------------------
+      99             : 
+     100       20299 : void BF2_lMIN2
+     101             : (
+     102             :     BF2_Tuple3_struct *z,
+     103             :     const BF2_Tuple3_struct *x,
+     104             :     const BF2_Tuple3_struct *y
+     105             : )
+     106             : {
+     107       20299 :     if (x->w < y->w
+     108        8956 :         || (x->w == y->w && x->h < y->h)
+     109        8956 :         || (x->w == y->w && x->h == y->h && x->pi < y->pi))
+     110             :     {
+     111       11626 :         if (z != x) { *z = *x; }
+     112             :     }
+     113             :     else
+     114             :     {
+     115        8673 :         *z = *y;
+     116             :     }
+     117       20299 : }
+     118             : 
+     119       20476 : void BF2_PLUSrhs2
+     120             : (
+     121             :     BF2_Tuple3_struct *z,
+     122             :     const BF2_Tuple3_struct *x,
+     123             :     const BF2_Tuple3_struct *y
+     124             : )
+     125             : {
+     126       20476 :     z->w = x->w + y->w ;
+     127       20476 :     z->h = x->h + y->h ;
+     128       20476 :     z->pi = (x->pi != UINT64_MAX && y->pi != 0) ?  y->pi : x->pi ;
+     129       20476 : }
+     130             : 
+     131        4424 : void BF2_EQ
+     132             : (
+     133             :     bool *z,
+     134             :     const BF2_Tuple3_struct *x,
+     135             :     const BF2_Tuple3_struct *y
+     136             : )
+     137             : {
+     138        4424 :     (*z) = (x->w == y->w && x->h == y->h && x->pi == y->pi) ;
+     139        4424 : }
+     140             : 
+     141             : // Given a n-by-n adjacency matrix A and a source vertex s.
+     142             : // If there is no negative-weight cycle reachable from s, return the distances
+     143             : // of shortest paths from s and parents along the paths as vector d. Otherwise,
+     144             : // returns d=NULL if there is a negtive-weight cycle.
+     145             : // pd_output is pointer to a GrB_Vector, where the i-th entry is d(s,i), the
+     146             : //   sum of edges length in the shortest path
+     147             : // ppi_output is pointer to a GrB_Vector, where the i-th entry is pi(i), the
+     148             : //   parent of i-th vertex in the shortest path
+     149             : // ph_output is pointer to a GrB_Vector, where the i-th entry is h(s,i), the
+     150             : //   number of edges from s to i in the shortest path
+     151             : // A has weights on corresponding entries of edges
+     152             : // s is given index for source vertex
+     153             : 
+     154           5 : GrB_Info LAGraph_BF_full2
+     155             : (
+     156             :     GrB_Vector *pd_output,      //the pointer to the vector of distance
+     157             :     GrB_Vector *ppi_output,     //the pointer to the vector of parent
+     158             :     GrB_Vector *ph_output,       //the pointer to the vector of hops
+     159             :     const GrB_Matrix A,         //matrix for the graph
+     160             :     const GrB_Index s           //given index of the source
+     161             : )
+     162             : {
+     163             :     GrB_Info info;
+     164           5 :     char *msg = NULL ;
+     165             :     // tmp vector to store distance vector after n (i.e., V) loops
+     166           5 :     GrB_Vector d = NULL, dtmp = NULL, dfrontier = NULL;
+     167           5 :     GrB_Matrix Atmp = NULL;
+     168             :     GrB_Type BF_Tuple3;
+     169             : 
+     170             :     GrB_BinaryOp BF_lMIN_Tuple3;
+     171             :     GrB_BinaryOp BF_PLUSrhs_Tuple3;
+     172             :     GrB_BinaryOp BF_EQ_Tuple3;
+     173             : 
+     174             :     GrB_Monoid BF_lMIN_Tuple3_Monoid;
+     175             :     GrB_Semiring BF_lMIN_PLUSrhs_Tuple3;
+     176             : 
+     177             :     GrB_Index nrows, ncols, n, nz;  // n = # of row/col, nz = # of nnz in graph
+     178           5 :     GrB_Index *I = NULL, *J = NULL; // for col/row indices of entries from A
+     179           5 :     GrB_Index *h = NULL, *pi = NULL;
+     180           5 :     double *w = NULL;
+     181           5 :     BF2_Tuple3_struct *W = NULL;
+     182             : 
+     183           5 :     LG_ASSERT (A != NULL && pd_output != NULL &&
+     184             :         ppi_output != NULL && ph_output != NULL, GrB_NULL_POINTER) ;
+     185             : 
+     186           5 :     *pd_output  = NULL;
+     187           5 :     *ppi_output = NULL;
+     188           5 :     *ph_output  = NULL;
+     189           5 :     GRB_TRY (GrB_Matrix_nrows (&nrows, A)) ;
+     190           5 :     GRB_TRY (GrB_Matrix_ncols (&ncols, A)) ;
+     191           5 :     GRB_TRY (GrB_Matrix_nvals (&nz, A));
+     192           5 :     LG_ASSERT_MSG (nrows == ncols, -1002, "A must be square") ;
+     193           5 :     n = nrows;
+     194           5 :     LG_ASSERT_MSG (s < n, GrB_INVALID_INDEX, "invalid source node") ;
+     195             : 
+     196             :     //--------------------------------------------------------------------------
+     197             :     // create all GrB_Type GrB_BinaryOp GrB_Monoid and GrB_Semiring
+     198             :     //--------------------------------------------------------------------------
+     199             :     // GrB_Type
+     200           5 :     GRB_TRY (GrB_Type_new(&BF_Tuple3, sizeof(BF2_Tuple3_struct)));
+     201             : 
+     202             :     // GrB_BinaryOp
+     203           5 :     GRB_TRY (GrB_BinaryOp_new(&BF_EQ_Tuple3,
+     204             :         (LAGraph_binary_function) (&BF2_EQ), GrB_BOOL, BF_Tuple3, BF_Tuple3));
+     205           5 :     GRB_TRY (GrB_BinaryOp_new(&BF_lMIN_Tuple3,
+     206             :         (LAGraph_binary_function) (&BF2_lMIN2),
+     207             :         BF_Tuple3, BF_Tuple3, BF_Tuple3));
+     208           5 :     GRB_TRY (GrB_BinaryOp_new(&BF_PLUSrhs_Tuple3,
+     209             :         (LAGraph_binary_function)(&BF2_PLUSrhs2),
+     210             :         BF_Tuple3, BF_Tuple3, BF_Tuple3));
+     211             : 
+     212             :     // GrB_Monoid
+     213           5 :     BF2_Tuple3_struct BF_identity = (BF2_Tuple3_struct) { .w = INFINITY,
+     214             :         .h = UINT64_MAX, .pi = UINT64_MAX };
+     215           5 :     GRB_TRY (GrB_Monoid_new_UDT(&BF_lMIN_Tuple3_Monoid, BF_lMIN_Tuple3,
+     216             :         &BF_identity));
+     217             : 
+     218             :     //GrB_Semiring
+     219           5 :     GRB_TRY (GrB_Semiring_new(&BF_lMIN_PLUSrhs_Tuple3,
+     220             :         BF_lMIN_Tuple3_Monoid, BF_PLUSrhs_Tuple3));
+     221             : 
+     222             :     //--------------------------------------------------------------------------
+     223             :     // allocate arrays used for tuplets
+     224             :     //--------------------------------------------------------------------------
+     225             : 
+     226           5 :     LAGRAPH_TRY (LAGraph_Malloc ((void **) &I, nz, sizeof(GrB_Index), msg)) ;
+     227           5 :     LAGRAPH_TRY (LAGraph_Malloc ((void **) &J, nz, sizeof(GrB_Index), msg)) ;
+     228           5 :     LAGRAPH_TRY (LAGraph_Malloc ((void **) &w, nz, sizeof(double), msg)) ;
+     229           5 :     LAGRAPH_TRY (LAGraph_Malloc ((void **) &W, nz, sizeof(BF2_Tuple3_struct),
+     230             :         msg)) ;
+     231             : 
+     232             :     //--------------------------------------------------------------------------
+     233             :     // create matrix Atmp based on A, while its entries become BF_Tuple3 type
+     234             :     //--------------------------------------------------------------------------
+     235             : 
+     236           5 :     GRB_TRY (GrB_Matrix_extractTuples_FP64(I, J, w, &nz, A));
+     237             :     int nthreads, nthreads_outer, nthreads_inner ;
+     238           5 :     LG_TRY (LAGraph_GetNumThreads (&nthreads_outer, &nthreads_inner, msg)) ;
+     239           5 :     nthreads = nthreads_outer * nthreads_inner ;
+     240           5 :     printf ("nthreads %d\n", nthreads) ;
+     241             :     int64_t k;
+     242             :     #pragma omp parallel for num_threads(nthreads) schedule(static)
+     243         773 :     for (k = 0; k < nz; k++)
+     244             :     {
+     245         768 :         if (w[k] == 0)             //diagonal entries
+     246             :         {
+     247           2 :             W[k] = (BF2_Tuple3_struct) { .w = 0, .h = 0, .pi = 0 };
+     248             :         }
+     249             :         else
+     250             :         {
+     251         766 :             W[k] = (BF2_Tuple3_struct) { .w = w[k], .h = 1, .pi = I[k] + 1 };
+     252             :         }
+     253             :     }
+     254           5 :     GRB_TRY (GrB_Matrix_new(&Atmp, BF_Tuple3, n, n));
+     255           5 :     GRB_TRY (GrB_Matrix_build_UDT(Atmp, I, J, W, nz, BF_lMIN_Tuple3));
+     256           5 :     LAGraph_Free ((void**)&I, NULL);
+     257           5 :     LAGraph_Free ((void**)&J, NULL);
+     258           5 :     LAGraph_Free ((void**)&W, NULL);
+     259           5 :     LAGraph_Free ((void**)&w, NULL);
+     260             : 
+     261             :     //--------------------------------------------------------------------------
+     262             :     // create and initialize "distance" vector d
+     263             :     //--------------------------------------------------------------------------
+     264           5 :     GRB_TRY (GrB_Vector_new(&d, BF_Tuple3, n));
+     265             :     // initial distance from s to itself
+     266           5 :     BF2_Tuple3_struct d0 = (BF2_Tuple3_struct) { .w = 0, .h = 0, .pi = 0 };
+     267           5 :     GRB_TRY (GrB_Vector_setElement_UDT(d, &d0, s));
+     268             : 
+     269             :     //--------------------------------------------------------------------------
+     270             :     // start the Bellman Ford process
+     271             :     //--------------------------------------------------------------------------
+     272             :     // copy d to dtmp in order to create a same size of vector
+     273           5 :     GRB_TRY (GrB_Vector_dup(&dtmp, d));
+     274           5 :     GRB_TRY (GrB_Vector_dup(&dfrontier, d));
+     275           5 :     bool same= false;          // variable indicating if d == dtmp
+     276           5 :     int64_t iter = 0;          // number of iterations
+     277             : 
+     278             :     // terminate when no new path is found or more than V-1 loops
+     279          93 :     while (!same && iter < n - 1)
+     280             :     {
+     281             :         // execute semiring on d and A, and save the result to dtmp
+     282          88 :         GRB_TRY (GrB_vxm(dfrontier, GrB_NULL, GrB_NULL,
+     283             :             BF_lMIN_PLUSrhs_Tuple3, dfrontier, Atmp, GrB_NULL));
+     284             : 
+     285             :         // dtmp[i] = min(d[i], dfrontier[i]).
+     286          88 :         GrB_Vector_eWiseAdd_BinaryOp(dtmp, GrB_NULL, GrB_NULL, BF_lMIN_Tuple3,
+     287             :             d, dfrontier, GrB_NULL);
+     288             : 
+     289          88 :         LG_TRY (LAGraph_Vector_IsEqualOp (&same, dtmp, d, BF_EQ_Tuple3, NULL));
+     290          88 :         if (!same)
+     291             :         {
+     292          85 :             GrB_Vector ttmp = dtmp;
+     293          85 :             dtmp = d;
+     294          85 :             d = ttmp;
+     295             :         }
+     296          88 :         iter ++;
+     297             :     }
+     298             : 
+     299             :     // check for negative-weight cycle only when there was a new path in the
+     300             :     // last loop, otherwise, there can't be a negative-weight cycle.
+     301           5 :     if (!same)
+     302             :     {
+     303             :         // execute semiring again to check for negative-weight cycle
+     304           2 :         GRB_TRY (GrB_vxm(dfrontier, GrB_NULL, GrB_NULL,
+     305             :             BF_lMIN_PLUSrhs_Tuple3, dfrontier, Atmp, GrB_NULL));
+     306             : 
+     307             :         // dtmp[i] = min(d[i], dfrontier[i]).
+     308           2 :         GrB_Vector_eWiseAdd_BinaryOp(dtmp, GrB_NULL, GrB_NULL, BF_lMIN_Tuple3,
+     309             :             d, dfrontier, GrB_NULL);
+     310             : 
+     311             :         // if d != dtmp, then there is a negative-weight cycle in the graph
+     312           2 :         LG_TRY (LAGraph_Vector_IsEqualOp (&same, dtmp, d, BF_EQ_Tuple3, NULL));
+     313           2 :         if (!same)
+     314             :         {
+     315             :             // printf("A negative-weight cycle found. \n");
+     316           2 :             LG_FREE_ALL;
+     317           2 :             return (GrB_NO_VALUE) ;
+     318             :         }
+     319             :     }
+     320             : 
+     321             :     //--------------------------------------------------------------------------
+     322             :     // extract tuple from "distance" vector d and create GrB_Vectors for output
+     323             :     //--------------------------------------------------------------------------
+     324             : 
+     325           3 :     LAGRAPH_TRY (LAGraph_Malloc ((void **) &I, n, sizeof(GrB_Index), msg)) ;
+     326           3 :     LAGRAPH_TRY (LAGraph_Malloc ((void **) &W, n, sizeof(BF2_Tuple3_struct),
+     327             :         msg)) ;
+     328           3 :     LAGRAPH_TRY (LAGraph_Malloc ((void **) &w, n, sizeof(double), msg)) ;
+     329           3 :     LAGRAPH_TRY (LAGraph_Malloc ((void **) &h, n, sizeof(GrB_Index), msg)) ;
+     330           3 :     LAGRAPH_TRY (LAGraph_Malloc ((void **) &pi, n, sizeof(GrB_Index), msg)) ;
+     331             : 
+     332           3 :     nz = n ;
+     333           3 :     GRB_TRY (GrB_Vector_extractTuples_UDT (I, (void *) W, &nz, d));
+     334             : 
+     335         111 :     for (k = 0; k < nz; k++)
+     336             :     {
+     337         108 :         w [k] = W[k].w ;
+     338         108 :         h [k] = W[k].h ;
+     339         108 :         pi[k] = W[k].pi;
+     340             :     }
+     341           3 :     GRB_TRY (GrB_Vector_new(pd_output,  GrB_FP64,   n));
+     342           3 :     GRB_TRY (GrB_Vector_new(ppi_output, GrB_UINT64, n));
+     343           3 :     GRB_TRY (GrB_Vector_new(ph_output,  GrB_UINT64, n));
+     344           3 :     GRB_TRY (GrB_Vector_build (*pd_output , I, w , nz, GrB_MIN_FP64  ));
+     345           3 :     GRB_TRY (GrB_Vector_build (*ppi_output, I, pi, nz, GrB_MIN_UINT64));
+     346           3 :     GRB_TRY (GrB_Vector_build (*ph_output , I, h , nz, GrB_MIN_UINT64));
+     347           3 :     LG_FREE_WORK;
+     348           3 :     return (GrB_SUCCESS) ;
+     349             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_BF_full_mxv.c.func-sort-c.html b/experimental/algorithm/LAGraph_BF_full_mxv.c.func-sort-c.html new file mode 100644 index 0000000000..c8b33e7140 --- /dev/null +++ b/experimental/algorithm/LAGraph_BF_full_mxv.c.func-sort-c.html @@ -0,0 +1,88 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_BF_full_mxv.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_BF_full_mxv.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:9494100.0 %
Date:2024-08-29 20:08:04Functions:44100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_BF_full_mxv5
BF_EQ_mxv4424
BF_lMIN_mxv20297
BF_PLUSrhs_mxv25194
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_BF_full_mxv.c.func.html b/experimental/algorithm/LAGraph_BF_full_mxv.c.func.html new file mode 100644 index 0000000000..8a92ac6eaf --- /dev/null +++ b/experimental/algorithm/LAGraph_BF_full_mxv.c.func.html @@ -0,0 +1,88 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_BF_full_mxv.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_BF_full_mxv.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:9494100.0 %
Date:2024-08-29 20:08:04Functions:44100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
BF_EQ_mxv4424
BF_PLUSrhs_mxv25194
BF_lMIN_mxv20297
LAGraph_BF_full_mxv5
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_BF_full_mxv.c.gcov.html b/experimental/algorithm/LAGraph_BF_full_mxv.c.gcov.html new file mode 100644 index 0000000000..a98290f731 --- /dev/null +++ b/experimental/algorithm/LAGraph_BF_full_mxv.c.gcov.html @@ -0,0 +1,414 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_BF_full_mxv.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_BF_full_mxv.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:9494100.0 %
Date:2024-08-29 20:08:04Functions:44100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_BF_full.c: Bellman-Ford single-source shortest paths, returns tree
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Jinhao Chen and Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // LAGraph_BF_full_mxv: Bellman-Ford single source shortest paths, returning
+      19             : // both the path lengths and the shortest-path tree.
+      20             : 
+      21             : // LAGraph_BF_full_mxv performs a Bellman-Ford to find out shortest path
+      22             : // length, parent nodes along the path and the hops (number of edges) in the
+      23             : // path from given source vertex s in the range of [0, n) on graph with n nodes.
+      24             : // It works almost the same as LAGraph_BF_full except that it performs update
+      25             : // using GrB_mxv instead of GrB_vxm, therefore, it require the input matrix as
+      26             : // the transpose of adjacency matrix A with size n by n. That is, the input
+      27             : // sparse matrix has entry AT(i, j) if there is edge from vertex j to vertex i
+      28             : // with weight w, then AT(i, j) = w. While same as LAGraph_BF_full, it requires
+      29             : // AT(i, i) = 0 for all 0 <= i < n.
+      30             : 
+      31             : // LAGraph_BF_full_mxv returns GrB_SUCCESS if it succeeds.  In this case, there
+      32             : // are no negative-weight cycles in the graph, and d, pi, and h are returned.
+      33             : // The vector d has d(k) as the shortest distance from s to k. pi(k) = p+1,
+      34             : // where p is the parent node of k-th node in the shortest path. In particular,
+      35             : // pi(s) = 0. h(k) = hop(s, k), the number of edges from s to k in the shortest
+      36             : // path.
+      37             : 
+      38             : // If the graph has a negative-weight cycle, GrB_NO_VALUE is returned, and the
+      39             : // GrB_Vectors d(k), pi(k) and h(k)  (i.e., *pd_output, *ppi_output and
+      40             : // *ph_output respectively) will be NULL when negative-weight cycle detected.
+      41             : 
+      42             : // Otherwise, other errors such as GrB_OUT_OF_MEMORY, GrB_INVALID_OBJECT, and
+      43             : // so on, can be returned, if these errors are found by the underlying
+      44             : // GrB_* functions.
+      45             : 
+      46             : 
+      47             : //------------------------------------------------------------------------------
+      48             : 
+      49             : #define LG_FREE_WORK                   \
+      50             : {                                      \
+      51             :     GrB_free(&d);                      \
+      52             :     GrB_free(&dtmp);                   \
+      53             :     GrB_free(&Atmp);                   \
+      54             :     GrB_free(&BF_Tuple3);              \
+      55             :     GrB_free(&BF_lMIN_Tuple3);         \
+      56             :     GrB_free(&BF_PLUSrhs_Tuple3);      \
+      57             :     GrB_free(&BF_EQ_Tuple3);           \
+      58             :     GrB_free(&BF_lMIN_Tuple3_Monoid);  \
+      59             :     GrB_free(&BF_lMIN_PLUSrhs_Tuple3); \
+      60             :     LAGraph_Free ((void**)&I, NULL);   \
+      61             :     LAGraph_Free ((void**)&J, NULL);   \
+      62             :     LAGraph_Free ((void**)&w, NULL);   \
+      63             :     LAGraph_Free ((void**)&W, NULL);   \
+      64             :     LAGraph_Free ((void**)&h, NULL);   \
+      65             :     LAGraph_Free ((void**)&pi, NULL);  \
+      66             : }
+      67             : 
+      68             : #define LG_FREE_ALL                    \
+      69             : {                                      \
+      70             :     LG_FREE_WORK ;                     \
+      71             :     GrB_free (pd_output);              \
+      72             :     GrB_free (ppi_output);             \
+      73             :     GrB_free (ph_output);              \
+      74             : }
+      75             : 
+      76             : #include <LAGraph.h>
+      77             : #include <LAGraphX.h>
+      78             : #include <LG_internal.h>  // from src/utility
+      79             : 
+      80             : typedef void (*LAGraph_binary_function) (void *, const void *, const void *) ;
+      81             : 
+      82             : //------------------------------------------------------------------------------
+      83             : // data type for each entry of the adjacent matrix A and "distance" vector d;
+      84             : // <INFINITY,INFINITY,INFINITY> corresponds to nonexistence of a path, and
+      85             : // the value  <0, 0, NULL> corresponds to a path from a vertex to itself
+      86             : //------------------------------------------------------------------------------
+      87             : 
+      88             : typedef struct
+      89             : {
+      90             :     double w;    // w  corresponds to a path weight.
+      91             :     GrB_Index h; // h  corresponds to a path size or number of hops.
+      92             :     GrB_Index pi;// pi corresponds to the penultimate vertex along a path.
+      93             :                  // vertex indexed as 1, 2, 3, ... , V, and pi = 0 (as nil)
+      94             :                  // for u=v, and pi = UINT64_MAX (as inf) for (u,v) not in E
+      95             : }
+      96             : BF_Tuple3_struct;
+      97             : 
+      98             : //------------------------------------------------------------------------------
+      99             : // binary functions, z=f(x,y), where Tuple3xTuple3 -> Tuple3
+     100             : //------------------------------------------------------------------------------
+     101             : 
+     102       20297 : void BF_lMIN_mxv
+     103             : (
+     104             :     BF_Tuple3_struct *z,
+     105             :     const BF_Tuple3_struct *y,
+     106             :     const BF_Tuple3_struct *x
+     107             : )
+     108             : {
+     109       20297 :     if (x->w < y->w
+     110       15239 :         || (x->w == y->w && x->h < y->h)
+     111       15239 :         || (x->w == y->w && x->h == y->h && x->pi < y->pi))
+     112             :     {
+     113        5058 :         if (z != x) { *z = *x; }
+     114             :     }
+     115             :     else
+     116             :     {
+     117       15239 :         *z = *y;
+     118             :     }
+     119       20297 : }
+     120             : 
+     121       25194 : void BF_PLUSrhs_mxv
+     122             : (
+     123             :     BF_Tuple3_struct *z,
+     124             :     const BF_Tuple3_struct *y,
+     125             :     const BF_Tuple3_struct *x
+     126             : )
+     127             : {
+     128       25194 :     z->w = x->w + y->w;
+     129       25194 :     z->h = x->h + y->h;
+     130       25194 :     z->pi = (x->pi != UINT64_MAX && y->pi != 0) ?  y->pi : x->pi ;
+     131       25194 : }
+     132             : 
+     133        4424 : void BF_EQ_mxv
+     134             : (
+     135             :     bool *z,
+     136             :     const BF_Tuple3_struct *y,
+     137             :     const BF_Tuple3_struct *x
+     138             : )
+     139             : {
+     140        4424 :     (*z) = (x->w == y->w && x->h == y->h && x->pi == y->pi) ;
+     141        4424 : }
+     142             : 
+     143             : // Given the transpose of a n-by-n adjacency matrix A and a source vertex s.
+     144             : // If there is no negative-weight cycle reachable from s, return the distances
+     145             : // of shortest paths from s and parents along the paths as vector d. Otherwise,
+     146             : // returns d=NULL if there is a negtive-weight cycle.
+     147             : // pd_output is pointer to a GrB_Vector, where the i-th entry is d(s,i), the
+     148             : //   sum of edges length in the shortest path
+     149             : // ppi_output is pointer to a GrB_Vector, where the i-th entry is pi(i), the
+     150             : //   parent of i-th vertex in the shortest path
+     151             : // ph_output is pointer to a GrB_Vector, where the i-th entry is h(s,i), the
+     152             : //   number of edges from s to i in the shortest path
+     153             : // AT has zeros on diagonal and weights on corresponding entries of edges
+     154             : // s is given index for source vertex
+     155             : 
+     156           5 : GrB_Info LAGraph_BF_full_mxv
+     157             : (
+     158             :     GrB_Vector *pd_output,      //the pointer to the vector of distance
+     159             :     GrB_Vector *ppi_output,     //the pointer to the vector of parent
+     160             :     GrB_Vector *ph_output,      //the pointer to the vector of hops
+     161             :     const GrB_Matrix AT,         //matrix for the graph
+     162             :     const GrB_Index s           //given index of the source
+     163             : )
+     164             : {
+     165             :     GrB_Info info;
+     166           5 :     char *msg = NULL ;
+     167             :     // tmp vector to store distance vector after n (i.e., V) loops
+     168           5 :     GrB_Vector d = NULL, dtmp = NULL;
+     169           5 :     GrB_Matrix Atmp = NULL;
+     170             :     GrB_Type BF_Tuple3;
+     171             : 
+     172             :     GrB_BinaryOp BF_lMIN_Tuple3;
+     173             :     GrB_BinaryOp BF_PLUSrhs_Tuple3;
+     174             :     GrB_BinaryOp BF_EQ_Tuple3;
+     175             : 
+     176             :     GrB_Monoid BF_lMIN_Tuple3_Monoid;
+     177             :     GrB_Semiring BF_lMIN_PLUSrhs_Tuple3;
+     178             : 
+     179             :     GrB_Index nrows, ncols, n, nz;  // n = # of row/col, nz = # of nnz in graph
+     180           5 :     GrB_Index *I = NULL, *J = NULL; // for col/row indices of entries from AT
+     181           5 :     GrB_Index *h = NULL, *pi = NULL;
+     182           5 :     double *w = NULL;
+     183           5 :     BF_Tuple3_struct *W = NULL;
+     184             : 
+     185           5 :     LG_ASSERT (AT != NULL && pd_output != NULL &&
+     186             :         ppi_output != NULL && ph_output != NULL, GrB_NULL_POINTER) ;
+     187             : 
+     188           5 :     *pd_output  = NULL;
+     189           5 :     *ppi_output = NULL;
+     190           5 :     *ph_output  = NULL;
+     191           5 :     GRB_TRY (GrB_Matrix_nrows (&nrows, AT)) ;
+     192           5 :     GRB_TRY (GrB_Matrix_ncols (&ncols, AT)) ;
+     193           5 :     GRB_TRY (GrB_Matrix_nvals (&nz, AT));
+     194           5 :     LG_ASSERT_MSG (nrows == ncols, -1002, "A must be square") ;
+     195           5 :     n = nrows;
+     196           5 :     LG_ASSERT_MSG (s < n, GrB_INVALID_INDEX, "invalid source node") ;
+     197             : 
+     198             :     //--------------------------------------------------------------------------
+     199             :     // create all GrB_Type GrB_BinaryOp GrB_Monoid and GrB_Semiring
+     200             :     //--------------------------------------------------------------------------
+     201             :     // GrB_Type
+     202           5 :     GRB_TRY (GrB_Type_new(&BF_Tuple3, sizeof(BF_Tuple3_struct)));
+     203             : 
+     204             :     // GrB_BinaryOp
+     205           5 :     GRB_TRY (GrB_BinaryOp_new(&BF_EQ_Tuple3,
+     206             :         (LAGraph_binary_function) (&BF_EQ_mxv),
+     207             :         GrB_BOOL, BF_Tuple3, BF_Tuple3));
+     208           5 :     GRB_TRY (GrB_BinaryOp_new(&BF_lMIN_Tuple3,
+     209             :         (LAGraph_binary_function) (&BF_lMIN_mxv),
+     210             :         BF_Tuple3, BF_Tuple3, BF_Tuple3));
+     211           5 :     GRB_TRY (GrB_BinaryOp_new(&BF_PLUSrhs_Tuple3,
+     212             :         (LAGraph_binary_function)(&BF_PLUSrhs_mxv),
+     213             :         BF_Tuple3, BF_Tuple3, BF_Tuple3));
+     214             : 
+     215             :     // GrB_Monoid
+     216           5 :     BF_Tuple3_struct BF_identity = (BF_Tuple3_struct) { .w = INFINITY,
+     217             :         .h = UINT64_MAX, .pi = UINT64_MAX };
+     218           5 :     GRB_TRY (GrB_Monoid_new_UDT(&BF_lMIN_Tuple3_Monoid, BF_lMIN_Tuple3,
+     219             :         &BF_identity));
+     220             : 
+     221             :     //GrB_Semiring
+     222           5 :     GRB_TRY (GrB_Semiring_new(&BF_lMIN_PLUSrhs_Tuple3,
+     223             :         BF_lMIN_Tuple3_Monoid, BF_PLUSrhs_Tuple3));
+     224             : 
+     225             :     //--------------------------------------------------------------------------
+     226             :     // allocate arrays used for tuplets
+     227             :     //--------------------------------------------------------------------------
+     228             : 
+     229           5 :     LAGRAPH_TRY (LAGraph_Malloc ((void **) &I, nz, sizeof(GrB_Index), msg)) ;
+     230           5 :     LAGRAPH_TRY (LAGraph_Malloc ((void **) &J, nz, sizeof(GrB_Index), msg)) ;
+     231           5 :     LAGRAPH_TRY (LAGraph_Malloc ((void **) &w, nz, sizeof(double), msg)) ;
+     232           5 :     LAGRAPH_TRY (LAGraph_Malloc ((void **) &W, nz, sizeof(BF_Tuple3_struct),
+     233             :         msg)) ;
+     234             : 
+     235             :     //--------------------------------------------------------------------------
+     236             :     // create matrix Atmp based on AT, while its entries become BF_Tuple3 type
+     237             :     //--------------------------------------------------------------------------
+     238           5 :     GRB_TRY (GrB_Matrix_extractTuples_FP64(I, J, w, &nz, AT));
+     239         951 :     for (GrB_Index k = 0; k < nz; k++)
+     240             :     {
+     241         946 :         if (w[k] == 0)             //diagonal entries
+     242             :         {
+     243         184 :             W[k] = (BF_Tuple3_struct) { .w = 0, .h = 0, .pi = 0 };
+     244             :         }
+     245             :         else
+     246             :         {
+     247             :             // w(i, j) is the weight of edge from j to i, so the parent here
+     248             :             // should be j
+     249         762 :             W[k] = (BF_Tuple3_struct) { .w = w[k], .h = 1, .pi = J[k] + 1 };
+     250             :         }
+     251             :     }
+     252           5 :     GRB_TRY (GrB_Matrix_new(&Atmp, BF_Tuple3, n, n));
+     253           5 :     GRB_TRY (GrB_Matrix_build_UDT(Atmp, I, J, W, nz, BF_lMIN_Tuple3));
+     254           5 :     LAGraph_Free ((void**)&I, NULL);
+     255           5 :     LAGraph_Free ((void**)&J, NULL);
+     256           5 :     LAGraph_Free ((void**)&W, NULL);
+     257           5 :     LAGraph_Free ((void**)&w, NULL);
+     258             : 
+     259             :     //--------------------------------------------------------------------------
+     260             :     // create and initialize "distance" vector d
+     261             :     //--------------------------------------------------------------------------
+     262           5 :     GRB_TRY (GrB_Vector_new(&d, BF_Tuple3, n));
+     263             :     // initial distance from s to itself
+     264           5 :     BF_Tuple3_struct d0 = (BF_Tuple3_struct) { .w = 0, .h = 0, .pi = 0 };
+     265           5 :     GRB_TRY (GrB_Vector_setElement_UDT(d, &d0, s));
+     266             : 
+     267             :     //--------------------------------------------------------------------------
+     268             :     // start the Bellman Ford process
+     269             :     //--------------------------------------------------------------------------
+     270             :     // copy d to dtmp in order to create a same size of vector
+     271           5 :     GRB_TRY (GrB_Vector_dup(&dtmp, d));
+     272           5 :     bool same= false;          // variable indicating if d == dtmp
+     273           5 :     int64_t iter = 0;          // number of iterations
+     274             : 
+     275             :     // terminate when no new path is found or more than V-1 loops
+     276          93 :     while (!same && iter < n - 1)
+     277             :     {
+     278             :         // execute semiring on d and AT, and save the result to dtmp
+     279          88 :         GRB_TRY (GrB_mxv(dtmp, GrB_NULL, GrB_NULL, BF_lMIN_PLUSrhs_Tuple3,
+     280             :             Atmp, d, GrB_NULL));
+     281          88 :         LG_TRY (LAGraph_Vector_IsEqualOp (&same, dtmp, d, BF_EQ_Tuple3, NULL));
+     282          88 :         if (!same)
+     283             :         {
+     284          85 :             GrB_Vector ttmp = dtmp;
+     285          85 :             dtmp = d;
+     286          85 :             d = ttmp;
+     287             :         }
+     288          88 :         iter ++;
+     289             :     }
+     290             : 
+     291             :     // check for negative-weight cycle only when there was a new path in the
+     292             :     // last loop, otherwise, there can't be a negative-weight cycle.
+     293           5 :     if (!same)
+     294             :     {
+     295             :         // execute semiring again to check for negative-weight cycle
+     296           2 :         GRB_TRY (GrB_mxv(dtmp, GrB_NULL, GrB_NULL, BF_lMIN_PLUSrhs_Tuple3,
+     297             :             Atmp, d, GrB_NULL));
+     298           2 :         LG_TRY (LAGraph_Vector_IsEqualOp (&same, dtmp, d, BF_EQ_Tuple3, NULL));
+     299             : 
+     300             :         // if d != dtmp, then there is a negative-weight cycle in the graph
+     301           2 :         if (!same)
+     302             :         {
+     303             :             // printf("A negative-weight cycle found. \n");
+     304           2 :             LG_FREE_ALL;
+     305           2 :             return (GrB_NO_VALUE) ;
+     306             :         }
+     307             :     }
+     308             : 
+     309             :     //--------------------------------------------------------------------------
+     310             :     // extract tuple from "distance" vector d and create GrB_Vectors for output
+     311             :     //--------------------------------------------------------------------------
+     312             : 
+     313           3 :     LAGRAPH_TRY (LAGraph_Malloc ((void **) &I, n, sizeof(GrB_Index), msg)) ;
+     314           3 :     LAGRAPH_TRY (LAGraph_Malloc ((void **) &W, n, sizeof(BF_Tuple3_struct),
+     315             :         msg)) ;
+     316           3 :     LAGRAPH_TRY (LAGraph_Malloc ((void **) &w, n, sizeof(double), msg)) ;
+     317           3 :     LAGRAPH_TRY (LAGraph_Malloc ((void **) &h, n, sizeof(GrB_Index), msg)) ;
+     318           3 :     LAGRAPH_TRY (LAGraph_Malloc ((void **) &pi, n, sizeof(GrB_Index), msg)) ;
+     319             : 
+     320           3 :     nz = n ;
+     321           3 :     GRB_TRY (GrB_Vector_extractTuples_UDT (I, (void *) W, &nz, d));
+     322             : 
+     323         111 :     for (GrB_Index k = 0; k < n; k++)
+     324             :     {
+     325         108 :         w [k] = W[k].w ;
+     326         108 :         h [k] = W[k].h ;
+     327         108 :         pi[k] = W[k].pi;
+     328             :     }
+     329             : 
+     330           3 :     GRB_TRY (GrB_Vector_new(pd_output,  GrB_FP64,   n));
+     331           3 :     GRB_TRY (GrB_Vector_new(ppi_output, GrB_UINT64, n));
+     332           3 :     GRB_TRY (GrB_Vector_new(ph_output,  GrB_UINT64, n));
+     333           3 :     GRB_TRY (GrB_Vector_build (*pd_output , I, w , nz, GrB_MIN_FP64  ));
+     334           3 :     GRB_TRY (GrB_Vector_build (*ppi_output, I, pi, nz, GrB_MIN_UINT64));
+     335           3 :     GRB_TRY (GrB_Vector_build (*ph_output , I, h , nz, GrB_MIN_UINT64));
+     336           3 :     LG_FREE_WORK;
+     337           3 :     return (GrB_SUCCESS) ;
+     338             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_BF_pure_c.c.func-sort-c.html b/experimental/algorithm/LAGraph_BF_pure_c.c.func-sort-c.html new file mode 100644 index 0000000000..862e6e79f1 --- /dev/null +++ b/experimental/algorithm/LAGraph_BF_pure_c.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_BF_pure_c.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_BF_pure_c.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3636100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_BF_pure_c3
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_BF_pure_c.c.func.html b/experimental/algorithm/LAGraph_BF_pure_c.c.func.html new file mode 100644 index 0000000000..7916b606e2 --- /dev/null +++ b/experimental/algorithm/LAGraph_BF_pure_c.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_BF_pure_c.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_BF_pure_c.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3636100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_BF_pure_c3
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_BF_pure_c.c.gcov.html b/experimental/algorithm/LAGraph_BF_pure_c.c.gcov.html new file mode 100644 index 0000000000..22673fa233 --- /dev/null +++ b/experimental/algorithm/LAGraph_BF_pure_c.c.gcov.html @@ -0,0 +1,212 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_BF_pure_c.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_BF_pure_c.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3636100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // BF_pure_c.c: Bellman-Ford method, not using GraphBLAS
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Jinhao Chen and Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // LAGraph_BF_pure_c: Bellman-Ford single source shortest paths, returning
+      19             : // both the path lengths and the shortest-path tree.
+      20             : 
+      21             : // LAGraph_BF_pure_c performs the Bellman-Ford algorithm to find out shortest
+      22             : // path length, parent nodes along the path from given source vertex s in the
+      23             : // range of [0, n) on graph with n nodes. It is implemented purely using
+      24             : // conventional method, and is single-threaded. It is used here for checking
+      25             : // the correctness of the result and comparison with the Bellman Ford
+      26             : // implemented based on LAGraph.  Therefore, it require the graph represented
+      27             : // as triplet format (I, J, W), which is an edge from vertex I(k) to vertex
+      28             : // J(k) with weight W(k), and also the number of vertices and number of edges.
+      29             : 
+      30             : // LAGraph_BF_pure_c returns GrB_SUCCESS, or GrB_NO_VALUE if it detects of
+      31             : // negative- weight cycle. The vector d(k) and pi(k) (i.e., *pd, and *ppi
+      32             : // respectively) will be NULL when negative-weight cycle detected. Otherwise,
+      33             : // the vector d has d(k) as the shortest distance from s to k. pi(k) = p, where
+      34             : // p is the parent node of k-th node in the shortest path. In particular, pi(s)
+      35             : // = -1.
+      36             : 
+      37             : //------------------------------------------------------------------------------
+      38             : 
+      39             : #define LG_FREE_ALL                     \
+      40             : {                                       \
+      41             :     LAGraph_Free ((void**) &d, NULL) ;  \
+      42             :     LAGraph_Free ((void**) &pi, NULL) ; \
+      43             : }
+      44             : 
+      45             : #include "LG_internal.h"
+      46             : #include <LAGraphX.h>
+      47             : 
+      48             : // Given the edges and corresponding weights of a graph in tuple
+      49             : // form {I, J, W} and a source vertex s. If there is no negative-weight
+      50             : // cycle reachable from s, returns GrB_SUCCESS and the shortest distance
+      51             : // d and the shortest path tree pi. Otherwise return NULL pointer for d
+      52             : // and pi.
+      53             : 
+      54           3 : GrB_Info LAGraph_BF_pure_c
+      55             : (
+      56             :     int32_t **pd,     // pointer to distance vector d, d(k) = shorstest distance
+      57             :                      // between s and k if k is reachable from s
+      58             :     int64_t **ppi,   // pointer to parent index vector pi, pi(k) = parent of
+      59             :                      // node k in the shortest path tree
+      60             :     const int64_t s, // given source node index
+      61             :     const int64_t n, // number of nodes
+      62             :     const int64_t nz,// number of edges
+      63             :     const int64_t *I,// row index vector
+      64             :     const int64_t *J,// column index vector
+      65             :     const int32_t  *W // weight vector, W(i) = weight of edge (I(i),J(i))
+      66             : )
+      67             : {
+      68           3 :     char *msg = NULL ;
+      69             :     int64_t i, j, k;
+      70           3 :     int32_t *d = NULL;
+      71           3 :     int64_t *pi = NULL;
+      72           3 :     LG_ASSERT (I != NULL && J != NULL && W != NULL && pd != NULL &&
+      73             :         ppi != NULL, GrB_NULL_POINTER) ;
+      74             : 
+      75           3 :     LAGraph_Free ((void **) pd, NULL) ;
+      76           3 :     LAGraph_Free ((void **) ppi, NULL) ;
+      77             : 
+      78           3 :     LG_ASSERT_MSG (s < n, GrB_INVALID_INDEX, "invalid source node") ;
+      79             : 
+      80             :     // allocate d and pi
+      81           3 :     LAGRAPH_TRY (LAGraph_Malloc((void **) &d,  n, sizeof(int32_t), msg));
+      82           3 :     LAGRAPH_TRY (LAGraph_Malloc((void **) &pi, n, sizeof(int64_t), msg));
+      83             : 
+      84             :     // initialize d to a vector of INF while set d(s) = 0
+      85             :     // and pi to a vector of -1
+      86          51 :     for (i = 0; i < n; i++)
+      87             :     {
+      88          48 :         d[i] = INT32_MAX;
+      89          48 :         pi[i] = -1;
+      90             :     }
+      91           3 :     d[s] = 0;
+      92             : 
+      93             :     // start the RELAX process and print results after each loop
+      94           3 :     bool new_path = true;     //variable indicating if new path is found
+      95           3 :     int64_t count = 0;        //number of loops
+      96             :     // terminate when no new path is found or more than n-1 loops
+      97          14 :     while(new_path && count < n-1)
+      98             :     {
+      99          11 :         new_path = false;
+     100         431 :         for (k = 0; k < nz; k++)
+     101             :         {
+     102         420 :             i = I[k];
+     103         420 :             j = J[k];
+     104         420 :             if (d[i] != INT32_MAX && (d[j] == INT32_MAX || d[j] > d[i] + W[k]))
+     105             :             {
+     106          83 :                 d[j] = d[i] + W[k];
+     107          83 :                 pi[j] = i;
+     108          83 :                 new_path = true;
+     109             :             }
+     110             :         }
+     111          11 :         count++;
+     112             :     }
+     113             : 
+     114             :     // check for negative-weight cycle only when there was a new path in the
+     115             :     // last loop, otherwise, there can't be a negative-weight cycle.
+     116           3 :     if (new_path)
+     117             :     {
+     118             :         // Do another loop of RELAX to check for negative loop,
+     119             :         // return true if there is negative-weight cycle;
+     120             :         // otherwise, print the distance vector and return false.
+     121           1 :         for (k = 0; k < nz; k++)
+     122             :         {
+     123           1 :             i = I[k];
+     124           1 :             j = J[k];
+     125           1 :             if (d[i] != INT32_MAX && (d[j] == INT32_MAX || d[j] > d[i] + W[k]))
+     126             :             {
+     127           1 :                 LG_FREE_ALL ;
+     128           1 :                 return (GrB_NO_VALUE) ;
+     129             :             }
+     130             :         }
+     131             :     }
+     132             : 
+     133           2 :     *pd = d;
+     134           2 :     *ppi = pi;
+     135           2 :     return (GrB_SUCCESS) ;
+     136             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_BF_pure_c_double.c.func-sort-c.html b/experimental/algorithm/LAGraph_BF_pure_c_double.c.func-sort-c.html new file mode 100644 index 0000000000..092f67dafd --- /dev/null +++ b/experimental/algorithm/LAGraph_BF_pure_c_double.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_BF_pure_c_double.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_BF_pure_c_double.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3636100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_BF_pure_c_double5
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_BF_pure_c_double.c.func.html b/experimental/algorithm/LAGraph_BF_pure_c_double.c.func.html new file mode 100644 index 0000000000..8b012f0141 --- /dev/null +++ b/experimental/algorithm/LAGraph_BF_pure_c_double.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_BF_pure_c_double.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_BF_pure_c_double.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3636100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_BF_pure_c_double5
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_BF_pure_c_double.c.gcov.html b/experimental/algorithm/LAGraph_BF_pure_c_double.c.gcov.html new file mode 100644 index 0000000000..846aaf0aa5 --- /dev/null +++ b/experimental/algorithm/LAGraph_BF_pure_c_double.c.gcov.html @@ -0,0 +1,214 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_BF_pure_c_double.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_BF_pure_c_double.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3636100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // BF_pure_c_double.c: Bellman-Ford method, not using GraphBLAS
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Jinhao Chen and Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // LAGraph_BF_pure_c_double: Bellman-Ford single source shortest paths,
+      19             : // returning both the path lengths and the shortest-path tree.
+      20             : 
+      21             : // LAGraph_BF_pure_c_double performs a Bellman-Ford to find out shortest path
+      22             : // length, parent nodes along the path from given source vertex s in the range
+      23             : // of [0, n) on graph with n nodes. It is implemented purely using conventional
+      24             : // method. It is used here for checking the correctness of the result and
+      25             : // comparison with the Bellman Ford implemented based on LAGraph. Therefore, it
+      26             : // require the graph represented as triplet format (I, J, W), which is an edge
+      27             : // from vertex I(k) to vertex J(k) with weight W(k), and also the number of
+      28             : // vertices and number of edges.
+      29             : 
+      30             : // LAGraph_BF_pure_c_double returns GrB_SUCCESS if it succeeds. In this case,
+      31             : // there are no negative-weight cycle in the graph, and d and pi are returned.
+      32             : // The vector d has d(k) as the distance from source noce to k-th node. pi(k) =
+      33             : // p, where p is the parent node of k-th node in the shortest path. In
+      34             : // particular, pi(s) = -1.
+      35             : 
+      36             : // If the graph has a negative-weight cycle, GrB_NO_VALUE is returned, and the
+      37             : // vectors d and pi (i.e., pd and ppi) will be NULL.
+      38             : 
+      39             : //------------------------------------------------------------------------------
+      40             : 
+      41             : #define LG_FREE_ALL                         \
+      42             : {                                           \
+      43             :     LAGraph_Free ((void**) &d, NULL) ;      \
+      44             :     LAGraph_Free ((void**) &pi, NULL) ;     \
+      45             : }
+      46             : 
+      47             : #include <float.h>
+      48             : 
+      49             : #include "LG_internal.h"
+      50             : #include <LAGraphX.h>
+      51             : 
+      52             : // Given the edges and corresponding weights of a graph in tuple
+      53             : // form {I, J, W} and a source vertex s. If there is no negative-weight
+      54             : // cycle reachable from s, returns GrB_SUCCESS and the shortest distance
+      55             : // d and the shortest path tree pi. Otherwise return NULL pointer for d
+      56             : // and pi.
+      57           5 : GrB_Info LAGraph_BF_pure_c_double
+      58             : (
+      59             :     double **pd,     // pointer to distance vector d, d(k) = shorstest distance
+      60             :                      // between s and k if k is reachable from s
+      61             :     int64_t **ppi,   // pointer to parent index vector pi, pi(k) = parent of
+      62             :                      // node k in the shortest path tree
+      63             :     const int64_t s, // given source node index
+      64             :     const int64_t n, // number of nodes
+      65             :     const int64_t nz,// number of edges
+      66             :     const int64_t *I,// row index vector
+      67             :     const int64_t *J,// column index vector
+      68             :     const double  *W // weight vector, W(i) = weight of edge (I(i),J(i))
+      69             : )
+      70             : {
+      71           5 :     char *msg = NULL ;
+      72             :     int64_t i, j, k;
+      73           5 :     double *d = NULL;
+      74           5 :     int64_t *pi = NULL;
+      75           5 :     LG_ASSERT (I != NULL && J != NULL && W != NULL && pd != NULL &&
+      76             :         ppi != NULL, GrB_NULL_POINTER) ;
+      77             : 
+      78           5 :     LAGraph_Free ((void **) pd, NULL) ;
+      79           5 :     LAGraph_Free ((void **) ppi, NULL) ;
+      80             : 
+      81           5 :     LG_ASSERT_MSG (s < n, GrB_INVALID_INDEX, "invalid source node") ;
+      82             : 
+      83             :     // allocate d and pi
+      84           5 :     LAGRAPH_TRY (LAGraph_Malloc((void **) &d,  n, sizeof(double), msg));
+      85           5 :     LAGRAPH_TRY (LAGraph_Malloc((void **) &pi, n, sizeof(int64_t), msg));
+      86             : 
+      87             :     // initialize d to a vector of INF while set d(s) = 0
+      88             :     // and pi to a vector of -1
+      89         187 :     for (i = 0; i < n; i++)
+      90             :     {
+      91         182 :         d[i] = INFINITY;
+      92         182 :         pi[i] = -1;
+      93             :     }
+      94           5 :     d[s] = 0;
+      95             :     // start the RELAX process and print results after each loop
+      96           5 :     bool new_path = true;     //variable indicating if new path is found
+      97           5 :     int64_t count = 0;        //number of loops
+      98             :     // terminate when no new path is found or more than n-1 loops
+      99          85 :     while(new_path && count < n-1)
+     100             :     {
+     101          80 :         new_path = false;
+     102       20786 :         for (k = 0; k < nz; k++)
+     103             :         {
+     104       20706 :             i = I[k];
+     105       20706 :             j = J[k];
+     106       20706 :             if (d[j] > d[i] + W[k])
+     107             :             {
+     108       11110 :                 d[j] = d[i] + W[k];
+     109       11110 :                 pi[j] = i;
+     110       11110 :                 new_path = true;
+     111             :             }
+     112             :         }
+     113          80 :         count++;
+     114             :     }
+     115             : 
+     116             :     // check for negative-weight cycle only when there was a new path in the
+     117             :     // last loop, otherwise, there can't be a negative-weight cycle.
+     118           5 :     if (new_path)
+     119             :     {
+     120             :         // Do another loop of RELAX to check for negative loop,
+     121             :         // return true if there is negative-weight cycle;
+     122             :         // otherwise, print the distance vector and return false.
+     123           4 :         for (k = 0; k < nz; k++)
+     124             :         {
+     125           4 :             i = I[k];
+     126           4 :             j = J[k];
+     127           4 :             if (d[j] > d[i] + W[k] + DBL_EPSILON*d[j])
+     128             :             {
+     129           2 :                 LG_FREE_ALL ;
+     130           2 :                 return (GrB_NO_VALUE) ;
+     131             :             }
+     132             :         }
+     133             :     }
+     134             : 
+     135           3 :     *pd = d;
+     136           3 :     *ppi = pi;
+     137           3 :     return (GrB_SUCCESS) ;
+     138             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_FastGraphletTransform.c.func-sort-c.html b/experimental/algorithm/LAGraph_FastGraphletTransform.c.func-sort-c.html new file mode 100644 index 0000000000..77077e4029 --- /dev/null +++ b/experimental/algorithm/LAGraph_FastGraphletTransform.c.func-sort-c.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_FastGraphletTransform.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_FastGraphletTransform.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:242242100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_FastGraphletTransform2
sub_one_mult993
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_FastGraphletTransform.c.func.html b/experimental/algorithm/LAGraph_FastGraphletTransform.c.func.html new file mode 100644 index 0000000000..2b01d03e94 --- /dev/null +++ b/experimental/algorithm/LAGraph_FastGraphletTransform.c.func.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_FastGraphletTransform.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_FastGraphletTransform.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:242242100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_FastGraphletTransform2
sub_one_mult993
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_FastGraphletTransform.c.gcov.html b/experimental/algorithm/LAGraph_FastGraphletTransform.c.gcov.html new file mode 100644 index 0000000000..7262fb59b1 --- /dev/null +++ b/experimental/algorithm/LAGraph_FastGraphletTransform.c.gcov.html @@ -0,0 +1,677 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_FastGraphletTransform.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_FastGraphletTransform.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:242242100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_FastGraphletTransform: fast graphlet transform
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Tanner Hoke, Texas A&M University, ...
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // LAGraph_FastGraphletTransform: computes the Fast Graphlet Transform of
+      19             : // an undirected graph.  No self edges are allowed on the input graph.
+      20             : 
+      21             : // fixme: rename this
+      22             : 
+      23             : // https://arxiv.org/pdf/2007.11111.pdf
+      24             : 
+      25             : //------------------------------------------------------------------------------
+      26             : #define F_UNARY(f)  ((void (*)(void *, const void *)) f)
+      27             : 
+      28             : #define LG_FREE_WORK                \
+      29             : {                                   \
+      30             :     GrB_free (&C_3) ;               \
+      31             :     GrB_free (&d_0) ;               \
+      32             :     GrB_free (&d_1) ;               \
+      33             :     GrB_free (&d_2) ;               \
+      34             :     GrB_free (&d_3) ;               \
+      35             :     GrB_free (&d_4) ;               \
+      36             :     GrB_free (&d_5) ;               \
+      37             :     GrB_free (&d_6) ;               \
+      38             :     GrB_free (&d_7) ;               \
+      39             :     GrB_free (&d_8) ;               \
+      40             :     GrB_free (&d_9) ;               \
+      41             :     GrB_free (&d_10) ;              \
+      42             :     GrB_free (&d_11) ;              \
+      43             :     GrB_free (&d_12) ;              \
+      44             :     GrB_free (&d_13) ;              \
+      45             :     GrB_free (&d_14) ;              \
+      46             :     GrB_free (&d_15) ;              \
+      47             :     GrB_free (&d_2) ;               \
+      48             :     GrB_free (&v) ;                 \
+      49             :     GrB_free (&p_1_minus_one) ;     \
+      50             :     GrB_free (&p_1_minus_two) ;     \
+      51             :     GrB_free (&two_c_3) ;           \
+      52             :     GrB_free (&p_1_p_1_had) ;       \
+      53             :     GrB_free (&C_42) ;              \
+      54             :     GrB_free (&P_2) ;               \
+      55             :     GrB_free (&D_1) ;               \
+      56             :     GrB_free (&D_4c) ;              \
+      57             :     GrB_free (&D_43) ;              \
+      58             :     GrB_free (&U_inv) ;             \
+      59             :     GrB_free (&F_raw) ;             \
+      60             :     GrB_free (&C_4) ;               \
+      61             :     GrB_free (&Sub_one_mult) ;      \
+      62             :     GrB_free (&T) ;                 \
+      63             :     if (A_Tiles != NULL)                                                \
+      64             :     {                                                                   \
+      65             :         for (int i = 0; i < tile_cnt; ++i) GrB_free (&A_Tiles [i]) ;    \
+      66             :     }                                                                   \
+      67             :     if (D_Tiles != NULL)                                                \
+      68             :     {                                                                   \
+      69             :         for (int i = 0; i < tile_cnt; ++i) GrB_free (&D_Tiles [i]) ;    \
+      70             :     }                                                                   \
+      71             :     if (C_Tiles != NULL)                                                \
+      72             :     {                                                                   \
+      73             :         for (int i = 0; i < tile_cnt; ++i) GrB_free (&C_Tiles [i]) ;    \
+      74             :     }                                                                   \
+      75             : }
+      76             : 
+      77             : #define LG_FREE_ALL                 \
+      78             : {                                   \
+      79             :     LG_FREE_WORK ;                  \
+      80             : }
+      81             : 
+      82             : #define F_UNARY(f)  ((void (*)(void *, const void *)) f)
+      83             : 
+      84             : #include "LG_internal.h"
+      85             : #include "LAGraphX.h"
+      86             : #ifdef _OPENMP
+      87             : #include <omp.h>
+      88             : #endif
+      89             : 
+      90         993 : void sub_one_mult (int64_t *z, const int64_t *x) { (*z) = (*x) * ((*x)-1) ; }
+      91             : 
+      92           2 : int LAGraph_FastGraphletTransform
+      93             : (
+      94             :     // outputs:
+      95             :     GrB_Matrix *F_net,  // 16-by-n matrix of graphlet counts
+      96             :     // inputs:
+      97             :     LAGraph_Graph G,
+      98             :     bool compute_d_15,  // probably this makes most sense
+      99             :     char *msg
+     100             : )
+     101             : {
+     102           2 :     LG_CLEAR_MSG ;
+     103           2 :     GrB_Index const U_inv_I[] = {0, 1, 2, 2, 3, 3, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 12, 12, 12, 12, 13, 13, 14, 14, 15} ;
+     104           2 :     GrB_Index const U_inv_J[] = {0, 1, 2, 4, 3, 4, 4, 5, 9, 10, 12, 13, 14, 15, 6, 10, 11, 12, 13, 14, 15, 7, 9, 10, 13, 14, 15, 8, 11, 14, 15, 9, 13, 15, 10, 13, 14, 15, 11, 14, 15, 12, 13, 14, 15, 13, 15, 14, 15, 15} ;
+     105           2 :     int64_t const U_inv_X[] = {1, 1, 1, -2, 1, -1, 1, 1, -2, -1, -2, 4, 2, -6, 1, -1, -2, -2, 2, 4, -6, 1, -1, -1, 2, 1, -3, 1, -1, 1, -1, 1, -2, 3, 1, -2, -2, 6, 1, -2, 3, 1, -1, -1, 3, 1, -3, 1, -3, 1} ;
+     106           2 :     GrB_Index const U_inv_nvals = 50;
+     107           2 :     GrB_UnaryOp Sub_one_mult = NULL ;
+     108           2 :     int tile_cnt = 0 ;
+     109           2 :     GrB_Matrix *A_Tiles = NULL ;
+     110           2 :     GrB_Matrix *D_Tiles = NULL ;
+     111           2 :     GrB_Matrix *C_Tiles = NULL ;
+     112           2 :     GrB_Index *Tile_nrows = NULL ;
+     113           2 :     GrB_Matrix T = NULL ;
+     114             : 
+     115           2 :     GrB_Matrix C_3 = NULL,
+     116           2 :                A = NULL,
+     117           2 :                C_42 = NULL,
+     118           2 :                P_2 = NULL,
+     119           2 :                D_1 = NULL,
+     120           2 :                D_4c = NULL,
+     121           2 :                D_43 = NULL,
+     122           2 :                U_inv = NULL,
+     123           2 :                F_raw = NULL,
+     124           2 :                C_4 = NULL ;
+     125             : 
+     126           2 :     GrB_Vector d_0 = NULL,
+     127           2 :                d_1 = NULL,
+     128           2 :                d_2 = NULL,
+     129           2 :                d_3 = NULL,
+     130           2 :                d_4 = NULL,
+     131           2 :                d_5 = NULL,
+     132           2 :                d_6 = NULL,
+     133           2 :                d_7 = NULL,
+     134           2 :                d_8 = NULL,
+     135           2 :                d_9 = NULL,
+     136           2 :                d_10 = NULL,
+     137           2 :                d_11 = NULL,
+     138           2 :                d_12 = NULL,
+     139           2 :                d_13 = NULL,
+     140           2 :                d_14 = NULL,
+     141           2 :                d_15 = NULL;
+     142             : 
+     143           2 :     GrB_Vector v = NULL,
+     144           2 :                two_c_3 = NULL,
+     145           2 :                p_1_minus_one = NULL,
+     146           2 :                p_1_minus_two = NULL,
+     147           2 :                p_1_p_1_had = NULL ;
+     148             : 
+     149             :     GrB_Index nvals ;
+     150             :     int64_t ntri ;
+     151             : 
+     152             : #if !LAGRAPH_SUITESPARSE
+     153             :     LG_ASSERT (false, GrB_NOT_IMPLEMENTED) ;
+     154             : #else
+     155             : 
+     156           2 :     A = G->A ;
+     157             : 
+     158             :     GrB_Index n ;
+     159           2 :     GRB_TRY (GrB_Matrix_nrows (&n, A)) ;
+     160             : 
+     161             :     //--------------------------------------------------------------------------
+     162             :     // compute d_0 = e
+     163             :     //--------------------------------------------------------------------------
+     164             : 
+     165             :     // d_0 = e
+     166           2 :     GRB_TRY (GrB_Vector_new (&d_0, GrB_INT64, n)) ;
+     167           2 :     GRB_TRY (GrB_assign (d_0, NULL, NULL, 1, GrB_ALL, n, NULL)) ;
+     168             : 
+     169             :     //--------------------------------------------------------------------------
+     170             :     // compute d_1 = Ae (in_degree)
+     171             :     //--------------------------------------------------------------------------
+     172             : 
+     173             : //  GRB_TRY (GrB_Vector_new (&d_1, GrB_INT64, n)) ;
+     174             : 
+     175             :     // d_1 = Ae (in_degree)
+     176           2 :     LG_TRY (LAGraph_Cached_OutDegree (G, msg)) ;
+     177             : 
+     178           2 :     GRB_TRY (GrB_Vector_dup (&d_1, G->out_degree)) ;
+     179             : 
+     180             :     //--------------------------------------------------------------------------
+     181             :     // compute d_2 = p_2
+     182             :     //--------------------------------------------------------------------------
+     183             : 
+     184           2 :     GRB_TRY (GrB_Vector_new (&d_2, GrB_INT64, n)) ;
+     185             : 
+     186             :     // d_2 = p_2 = A*p_1 - c_2 = A*d_1 - d_1
+     187           2 :     GRB_TRY (GrB_mxv (d_2, NULL, NULL, GxB_PLUS_SECOND_INT64, A, d_1, NULL)) ;
+     188           2 :     GRB_TRY (GrB_eWiseMult (d_2, NULL, NULL, GrB_MINUS_INT64, d_2, d_1, NULL)) ;
+     189             : 
+     190             :     //--------------------------------------------------------------------------
+     191             :     // compute d_3 = hadamard(p_1, p_1 - 1) / 2
+     192             :     //--------------------------------------------------------------------------
+     193             : 
+     194           2 :     GRB_TRY (GrB_Vector_new (&d_3, GrB_INT64, n)) ;
+     195             : 
+     196           2 :     GRB_TRY (GrB_UnaryOp_new (&Sub_one_mult, F_UNARY (sub_one_mult), GrB_INT64, GrB_INT64)) ;
+     197             : 
+     198           2 :     GRB_TRY (GrB_apply (d_3, NULL, NULL, Sub_one_mult, d_1, NULL)) ;
+     199           2 :     GRB_TRY (GrB_apply (d_3, NULL, NULL, GrB_DIV_INT64, d_3, (int64_t) 2, NULL)) ;
+     200             : 
+     201             :     //--------------------------------------------------------------------------
+     202             :     // compute d_4 = C_3e/2
+     203             :     //--------------------------------------------------------------------------
+     204             : 
+     205           2 :     GRB_TRY (GrB_Matrix_new (&C_3, GrB_INT64, n, n)) ;
+     206           2 :     GRB_TRY (GrB_Vector_new (&d_4, GrB_INT64, n)) ;
+     207             : 
+     208             :     // C_3 = hadamard(A, A^2)
+     209           2 :     GRB_TRY (GrB_mxm (C_3, A, NULL, GxB_PLUS_FIRST_INT64, A, A, GrB_DESC_ST1)) ;
+     210             : 
+     211             :     // d_4 = c_3 = C_3e/2
+     212           2 :     GRB_TRY (GrB_reduce (d_4, NULL, NULL, GrB_PLUS_MONOID_INT64, C_3, NULL)) ;
+     213           2 :     GRB_TRY (GrB_apply (d_4, NULL, NULL, GrB_DIV_INT64, d_4, (int64_t) 2, NULL)) ;
+     214             : 
+     215             :     //--------------------------------------------------------------------------
+     216             :     // compute d_5 = p_3 = A*d_2 - hadamard(p_1, p_1 - 1) - 2c_3
+     217             :     //--------------------------------------------------------------------------
+     218             : 
+     219           2 :     GRB_TRY (GrB_Vector_new (&v, GrB_INT64, n)) ;
+     220           2 :     GRB_TRY (GrB_Vector_new (&two_c_3, GrB_INT64, n)) ;
+     221           2 :     GRB_TRY (GrB_Vector_new (&d_5, GrB_INT64, n)) ;
+     222             : 
+     223             :     // v = hadamard(p_1, p_1 - 1)
+     224           2 :     GRB_TRY (GrB_apply (v, NULL, NULL, Sub_one_mult, d_1, NULL)) ;
+     225             : 
+     226             :     // two_c_3 = 2 * c_3 = 2 * d_4
+     227           2 :     GRB_TRY (GrB_apply (two_c_3, NULL, NULL, GrB_TIMES_INT64, 2, d_4, NULL)) ;
+     228             : 
+     229             :     // d_5 = A * d_2
+     230           2 :     GRB_TRY (GrB_mxv (d_5, NULL, NULL, GxB_PLUS_SECOND_INT64, A, d_2, NULL)) ;
+     231             : 
+     232             :     // d_5 -= hadamard(p_1, p_1 - 1)
+     233           2 :     GRB_TRY (GrB_eWiseAdd (d_5, NULL, NULL, GrB_MINUS_INT64, d_5, v, NULL)) ;
+     234             : 
+     235             :     // d_5 -= two_c_3
+     236           2 :     GRB_TRY (GrB_eWiseAdd (d_5, NULL, NULL, GrB_MINUS_INT64, d_5, two_c_3, NULL)) ;
+     237             : 
+     238             :     //--------------------------------------------------------------------------
+     239             :     // compute d_6 = hadamard(d_2, p_1-1) - 2c_3
+     240             :     //--------------------------------------------------------------------------
+     241             : 
+     242           2 :     GRB_TRY (GrB_Vector_new (&p_1_minus_one, GrB_INT64, n)) ;
+     243           2 :     GRB_TRY (GrB_Vector_new (&d_6, GrB_INT64, n)) ;
+     244             : 
+     245             :     // p_1_minus_one = p_1 - 1
+     246           2 :     GRB_TRY (GrB_apply (p_1_minus_one, NULL, NULL, GrB_MINUS_INT64, d_1, (int64_t) 1, NULL)) ;
+     247             : 
+     248             :     // d_6 = hadamard(d_2, p_1-1)
+     249           2 :     GRB_TRY (GrB_eWiseMult (d_6, NULL, NULL, GrB_TIMES_INT64, d_2, p_1_minus_one, NULL)) ;
+     250             : 
+     251             :     // d_6 -= 2c_3
+     252           2 :     GRB_TRY (GrB_eWiseAdd (d_6, NULL, NULL, GrB_MINUS_INT64, d_6, two_c_3, NULL)) ;
+     253             : 
+     254             :     //--------------------------------------------------------------------------
+     255             :     // compute d_7 = A*hadamard(p_1-1, p_1-2) / 2
+     256             :     //--------------------------------------------------------------------------
+     257             : 
+     258           2 :     GRB_TRY (GrB_Vector_new (&p_1_minus_two, GrB_INT64, n)) ;
+     259           2 :     GRB_TRY (GrB_Vector_new (&p_1_p_1_had, GrB_INT64, n)) ;
+     260           2 :     GRB_TRY (GrB_Vector_new (&d_7, GrB_INT64, n)) ;
+     261             : 
+     262           2 :     GRB_TRY (GrB_apply (p_1_minus_two, NULL, NULL, GrB_MINUS_INT64, d_1, (int64_t) 2, NULL)) ;
+     263           2 :     GRB_TRY (GrB_eWiseMult (p_1_p_1_had, NULL, NULL, GrB_TIMES_INT64, p_1_minus_one, p_1_minus_two, NULL)) ;
+     264             : 
+     265           2 :     GRB_TRY (GrB_mxv (d_7, NULL, NULL, GxB_PLUS_SECOND_INT64, A, p_1_p_1_had, NULL)) ;
+     266           2 :     GRB_TRY (GrB_apply (d_7, NULL, NULL, GrB_DIV_INT64, d_7, (int64_t) 2, NULL)) ;
+     267             : 
+     268             :     //--------------------------------------------------------------------------
+     269             :     // compute d_8 = hadamard(p_1, p_1_p_1_had) / 6
+     270             :     //--------------------------------------------------------------------------
+     271             : 
+     272           2 :     GRB_TRY (GrB_Vector_new (&d_8, GrB_INT64, n)) ;
+     273             : 
+     274           2 :     GRB_TRY (GrB_eWiseMult (d_8, NULL, NULL, GrB_TIMES_INT64, d_1, p_1_p_1_had, NULL)) ;
+     275           2 :     GRB_TRY (GrB_apply (d_8, NULL, NULL, GrB_DIV_INT64, d_8, (int64_t) 6, NULL)) ;
+     276             : 
+     277             :     //--------------------------------------------------------------------------
+     278             :     // compute d_9 = A*c_3 - 2*c_3
+     279             :     //--------------------------------------------------------------------------
+     280             : 
+     281           2 :     GRB_TRY (GrB_Vector_new (&d_9, GrB_INT64, n)) ;
+     282             : 
+     283           2 :     GRB_TRY (GrB_mxv (d_9, NULL, NULL, GxB_PLUS_SECOND_INT64, A, d_4, NULL)) ;
+     284           2 :     GRB_TRY (GrB_eWiseAdd (d_9, NULL, NULL, GrB_MINUS_INT64, d_9, two_c_3, NULL)) ;
+     285             : 
+     286             :     //--------------------------------------------------------------------------
+     287             :     // compute d_10 = C_3 * (p_1 - 2)
+     288             :     //--------------------------------------------------------------------------
+     289             : 
+     290           2 :     GRB_TRY (GrB_Vector_new (&d_10, GrB_INT64, n)) ;
+     291             : 
+     292           2 :     GRB_TRY (GrB_mxv (d_10, NULL, NULL, GxB_PLUS_TIMES_INT64, C_3, p_1_minus_two, NULL)) ;
+     293             : 
+     294             :     //--------------------------------------------------------------------------
+     295             :     // compute d_11 = hadamard(p_1 - 2, c_3)
+     296             :     //--------------------------------------------------------------------------
+     297             : 
+     298           2 :     GRB_TRY (GrB_Vector_new (&d_11, GrB_INT64, n)) ;
+     299             : 
+     300           2 :     GRB_TRY (GrB_eWiseMult (d_11, NULL, NULL, GrB_TIMES_INT64, p_1_minus_two, d_4, NULL)) ;
+     301             : 
+     302             :     //--------------------------------------------------------------------------
+     303             :     // compute d_12 = c_4 = C_{4,2}e/2
+     304             :     //--------------------------------------------------------------------------
+     305             : 
+     306           2 :     GRB_TRY (GrB_Matrix_new (&C_4, GrB_INT64, n, 1)) ;
+     307           2 :     GRB_TRY (GrB_Matrix_new (&D_1, GrB_INT64, n, n)) ;
+     308             : 
+     309           2 :     GRB_TRY (GrB_Vector_new (&d_12, GrB_INT64, n)) ;
+     310             : 
+     311             :     // D_1 = diag(d_1)
+     312           2 :     GRB_TRY (GxB_Matrix_diag (D_1, d_1, (int64_t) 0, NULL)) ;
+     313             : 
+     314           2 :     GRB_TRY (GrB_Matrix_nvals (&nvals, A));
+     315             : 
+     316           2 :     const GrB_Index entries_per_tile = 1000;
+     317           2 :     GrB_Index ntiles = (nvals + entries_per_tile - 1) / entries_per_tile ;
+     318             :     // FIXME: use LAGraph_Calloc here, and check if out of memory:
+     319           2 :     A_Tiles = calloc (ntiles , sizeof (GrB_Matrix)) ;
+     320           2 :     D_Tiles = calloc (ntiles , sizeof (GrB_Matrix)) ;
+     321           2 :     C_Tiles = calloc (ntiles , sizeof (GrB_Matrix)) ;
+     322           2 :     Tile_nrows = calloc (ntiles , sizeof (GrB_Index)) ;
+     323           2 :     GrB_Index Tile_ncols [1] = {n} ;
+     324             : 
+     325           2 :     int64_t tot_deg = 0 ;
+     326           2 :     GrB_Index last_row = -1 ;
+     327          43 :     for (GrB_Index i = 0; i < n; ++i) {
+     328          41 :         int64_t deg = 0 ;
+     329          41 :         GRB_TRY (GrB_Vector_extractElement (&deg, d_1, i)) ;
+     330             : 
+     331          41 :         if (i == n - 1 || (tot_deg / entries_per_tile != (tot_deg + deg) / entries_per_tile)) {
+     332           2 :             Tile_nrows [tile_cnt++] = i - last_row ;
+     333           2 :             last_row = i ;
+     334             :         }
+     335             : 
+     336          41 :         tot_deg += deg ;
+     337             :     }
+     338             : 
+     339           2 :     GRB_TRY (GxB_Matrix_split (A_Tiles, tile_cnt, 1, Tile_nrows, Tile_ncols, A, NULL)) ;
+     340           2 :     GRB_TRY (GxB_Matrix_split (D_Tiles, tile_cnt, 1, Tile_nrows, Tile_ncols, D_1, NULL)) ;
+     341             : 
+     342             : #define TRY(method)                         \
+     343             :     {                                       \
+     344             :         GrB_Info info2 = method ;           \
+     345             :         if (info2 != GrB_SUCCESS)           \
+     346             :         {                                   \
+     347             :             GrB_free (&A_i) ;               \
+     348             :             GrB_free (&C_Tiles [i_tile]) ;  \
+     349             :             GrB_free (&e) ;                 \
+     350             :             info1 = info2 ;                 \
+     351             :             continue ;                      \
+     352             :         }                                   \
+     353             :     }
+     354             : 
+     355             : //  GxB_set (GxB_NTHREADS, 1) ;
+     356             :     int save_nthreads_outer, save_nthreads_inner ;
+     357           2 :     LG_TRY (LAGraph_GetNumThreads (&save_nthreads_outer, &save_nthreads_inner, msg)) ;
+     358           2 :     LG_TRY (LAGraph_SetNumThreads (1, 1, msg)) ;
+     359             : 
+     360             :     int i_tile;
+     361           2 :     GrB_Info info1 = GrB_SUCCESS ;
+     362             :     #pragma omp parallel for num_threads(omp_get_max_threads()) schedule(dynamic,1)
+     363           4 :     for (i_tile = 0; i_tile < tile_cnt; ++i_tile) {
+     364           2 :         GrB_Matrix A_i = NULL, e = NULL ;
+     365             : 
+     366           2 :         TRY (GrB_Matrix_new (&e, GrB_INT64, n, 1)) ;
+     367           2 :         TRY (GrB_assign (e, NULL, NULL, (int64_t) 1, GrB_ALL, n, GrB_ALL, 1, NULL)) ;
+     368             : 
+     369           2 :         TRY (GrB_Matrix_new (&A_i, GrB_INT64, Tile_nrows [i_tile], n)) ;
+     370           2 :         TRY (GrB_Matrix_new (&C_Tiles [i_tile], GrB_INT64, Tile_nrows [i_tile], 1)) ;
+     371             : 
+     372           2 :         TRY (GrB_mxm (A_i, NULL, NULL, GxB_PLUS_PAIR_INT64, A_Tiles [i_tile], A, NULL)) ;
+     373           2 :         TRY (GrB_eWiseAdd (A_i, NULL, NULL, GrB_MINUS_INT64, A_i, D_Tiles [i_tile], NULL)) ;
+     374           2 :         TRY (GrB_apply (A_i, NULL, NULL, Sub_one_mult, A_i, NULL)) ;
+     375             : 
+     376             :         // multiply A_i by it on the right
+     377           2 :         TRY (GrB_mxm (C_Tiles [i_tile], NULL, NULL, GxB_PLUS_FIRST_INT64, A_i, e, NULL)) ;
+     378             : 
+     379           2 :         GrB_free (&A_i) ;
+     380           2 :         GrB_free (&e) ;
+     381             :     }
+     382             : 
+     383           2 :     GRB_TRY (info1) ;
+     384             : 
+     385             : //  GxB_set (GxB_NTHREADS, omp_get_max_threads()) ;
+     386           2 :     LG_TRY (LAGraph_SetNumThreads (save_nthreads_outer, save_nthreads_inner, msg)) ;
+     387             : 
+     388           2 :     GRB_TRY (GxB_Matrix_concat (C_4, C_Tiles, tile_cnt, 1, NULL)) ;
+     389             : 
+     390             :     // d_12 = C_4
+     391           2 :     GRB_TRY (GrB_reduce (d_12, NULL, NULL, GrB_PLUS_MONOID_INT64, C_4, NULL)) ;
+     392           2 :     GRB_TRY (GrB_apply (d_12, NULL, NULL, GrB_DIV_INT64, d_12, 2, NULL)) ;
+     393             : 
+     394             :     //--------------------------------------------------------------------------
+     395             :     // compute d_13 = D_{4,c}e/2
+     396             :     //--------------------------------------------------------------------------
+     397             : 
+     398           2 :     GRB_TRY (GrB_Matrix_new (&D_4c, GrB_INT64, n, n)) ;
+     399           2 :     GRB_TRY (GrB_Vector_new (&d_13, GrB_INT64, n)) ;
+     400             : 
+     401           2 :     GRB_TRY (GrB_eWiseMult (D_4c, NULL, NULL, GrB_MINUS_INT64, C_3, A, NULL)) ; // can be mult because we mask with A next
+     402           2 :     GRB_TRY (GrB_mxm (D_4c, A, NULL, GxB_PLUS_SECOND_INT64, A, D_4c, GrB_DESC_S)) ;
+     403             : 
+     404             :     // d_13  = D_{4,c}*e/2
+     405           2 :     GRB_TRY (GrB_reduce (d_13, NULL, NULL, GrB_PLUS_INT64, D_4c, NULL)) ;
+     406           2 :     GRB_TRY (GrB_apply (d_13, NULL, NULL, GrB_DIV_INT64, d_13, (int64_t) 2, NULL)) ;
+     407             : 
+     408             :     //--------------------------------------------------------------------------
+     409             :     // compute d_14 = D_{4,3}e/2 = hadamard(A, C_42)e/2
+     410             :     //--------------------------------------------------------------------------
+     411             : 
+     412           2 :     GRB_TRY (GrB_Matrix_new (&D_43, GrB_INT64, n, n)) ;
+     413           2 :     GRB_TRY (GrB_Vector_new (&d_14, GrB_INT64, n)) ;
+     414           2 :     GRB_TRY (GrB_Matrix_new (&C_42, GrB_INT64, n, n)) ;
+     415           2 :     GRB_TRY (GrB_Matrix_new (&P_2, GrB_INT64, n, n)) ;
+     416             : 
+     417             :     // P_2 = A*A - diag(d_1)
+     418           2 :     GRB_TRY (GrB_eWiseAdd (P_2, A, NULL, GrB_MINUS_INT64, C_3, D_1, NULL)) ;
+     419             : 
+     420             :     // C_42 = hadamard(P_2, P_2 - 1)
+     421           2 :     GRB_TRY (GrB_apply (C_42, A, NULL, Sub_one_mult, P_2, NULL)) ;
+     422             : 
+     423           2 :     GRB_TRY (GrB_eWiseMult (D_43, NULL, NULL, GrB_TIMES_INT64, A, C_42, NULL)) ;
+     424             : 
+     425             :     // d_14  = D_{4,3}*e/2
+     426           2 :     GRB_TRY (GrB_reduce (d_14, NULL, NULL, GrB_PLUS_INT64, D_43, NULL)) ;
+     427           2 :     GRB_TRY (GrB_apply (d_14, NULL, NULL, GrB_DIV_INT64, d_14, (int64_t) 2, NULL)) ;
+     428             : 
+     429             :     //--------------------------------------------------------------------------
+     430             :     // compute d_15 = Te/6
+     431             :     //--------------------------------------------------------------------------
+     432             : 
+     433           2 :     if (compute_d_15) {
+     434           2 :         LG_TRY (LAGraph_KTruss (&T, G, 4, msg)) ;
+     435           2 :         GRB_TRY (GrB_Vector_new (&d_15, GrB_INT64, n)) ;
+     436             : 
+     437           2 :         int nthreads = 1 ;
+     438             :         // todo: parallelize this...
+     439             : //#pragma omp parallel for num_threads(nthreads)
+     440             :         //for (int tid = 0 ; tid < nthreads ; tid++)
+     441             :         {
+     442           2 :             GrB_Index *neighbors = (GrB_Index*) malloc(n * sizeof(GrB_Index));
+     443           2 :             GrB_Index *k4cmn = (GrB_Index*) malloc(n * sizeof(GrB_Index));
+     444           2 :             int64_t *f15 = (int64_t*) malloc(n * sizeof(int64_t));
+     445           2 :             GrB_Index *I = (GrB_Index *) malloc(n * sizeof(GrB_Index));
+     446           2 :             int *isNeighbor = (int*) malloc(n * sizeof(int));
+     447          43 :             for (int i = 0; i < n; ++i) {
+     448          41 :                 neighbors [i] = k4cmn [i] = f15 [i] = isNeighbor [i] = 0 ;
+     449          41 :                 I [i] = i ;
+     450             :             }
+     451             : 
+     452             : 
+     453             :             // thread tid operates on T(row1:row2-1,:)
+     454           2 :             GrB_Index row1 = 0;//tid * (n / nthreads) ;
+     455           2 :             GrB_Index row2 = n;//(tid == nthreads - 1) ? n : ((tid+1) * (n / nthreads)) ;
+     456             : 
+     457             :             GxB_Iterator riterator ;
+     458           2 :             GxB_Iterator_new (&riterator) ;
+     459           2 :             GRB_TRY (GxB_rowIterator_attach (riterator, T, NULL)) ;
+     460             : 
+     461             :             GxB_Iterator iterator ;
+     462           2 :             GxB_Iterator_new (&iterator) ;
+     463           2 :             GRB_TRY (GxB_rowIterator_attach (iterator, T, NULL)) ;
+     464             : 
+     465             :             // seek to T(row1,:)
+     466           2 :             GrB_Info info = GxB_rowIterator_seekRow (iterator, row1) ;
+     467          43 :             while (info != GxB_EXHAUSTED)
+     468             :             {
+     469             :                 // iterate over entries in T(i,:)
+     470          41 :                 GrB_Index idx2 = GxB_rowIterator_getRowIndex (iterator) ;
+     471          41 :                 if (idx2 >= row2) break ;
+     472          41 :                 int neighbor_cnt = 0 ;
+     473         109 :                 while (info == GrB_SUCCESS)
+     474             :                 {
+     475             :                     // working with edge (idx2, j)
+     476          68 :                     GrB_Index j = GxB_rowIterator_getColIndex (iterator) ;
+     477             : 
+     478          68 :                     if (j > idx2) {
+     479          34 :                         neighbors [neighbor_cnt++] = j ;
+     480          34 :                         isNeighbor [j] = 1 ;
+     481             :                     }
+     482             : 
+     483          68 :                     info = GxB_rowIterator_nextCol (iterator) ;
+     484             :                 }
+     485             : 
+     486          75 :                 for (int neighbor_id = 0 ; neighbor_id < neighbor_cnt ; ++neighbor_id) {
+     487          34 :                     GrB_Index j = neighbors [neighbor_id] ;
+     488          34 :                     int cmn_cnt = 0 ;
+     489          34 :                     info = GxB_rowIterator_seekRow(riterator, j) ;
+     490             : 
+     491         180 :                     while (info == GrB_SUCCESS) { // iterate over neighbors of j
+     492         146 :                         GrB_Index k = GxB_rowIterator_getColIndex (riterator) ;
+     493         146 :                         if (k > j && isNeighbor [k]) {
+     494          31 :                             k4cmn [cmn_cnt++] = k ;
+     495          31 :                             isNeighbor [k] = -1 ;
+     496             :                         }
+     497         146 :                         info = GxB_rowIterator_nextCol (riterator) ;
+     498             :                     }
+     499             :                     // check every combination
+     500          65 :                     for (int k_1 = 0 ; k_1 < cmn_cnt ; k_1++) {
+     501          31 :                         GrB_Index k = k4cmn [k_1] ;
+     502          31 :                         info = GxB_rowIterator_seekRow(riterator, k) ;
+     503             : 
+     504         164 :                         while (info == GrB_SUCCESS) { // iterate over neighbors of k
+     505         133 :                             GrB_Index l = GxB_rowIterator_getColIndex (riterator) ;
+     506         133 :                             if (l > k && isNeighbor [l] == -1) {
+     507          13 :                                 f15[idx2]++ ;
+     508          13 :                                 f15[j]++ ;
+     509          13 :                                 f15[k]++ ;
+     510          13 :                                 f15[l]++ ;
+     511             :                             }
+     512         133 :                             info = GxB_rowIterator_nextCol (riterator) ;
+     513             :                         }
+     514             :                     }
+     515          65 :                     for (int k_1 = 0 ; k_1 < cmn_cnt ; k_1++) {
+     516          31 :                         isNeighbor[k4cmn[k_1]] = 1 ;
+     517             :                     }
+     518             :                 }
+     519             : 
+     520          75 :                 for (int neighbor_id = 0 ; neighbor_id < neighbor_cnt ; ++neighbor_id) {
+     521          34 :                     GrB_Index j = neighbors [neighbor_id] ;
+     522          34 :                     isNeighbor [j] = 0 ;
+     523             :                 }
+     524             : 
+     525             :                 // move to the next row, T(i+1,:)
+     526          41 :                 info = GxB_rowIterator_nextRow (iterator) ;
+     527             :             }
+     528           2 :             GrB_free (&iterator) ;
+     529           2 :             GrB_free (&riterator) ;
+     530           2 :             GrB_free (&T) ;
+     531           2 :             GRB_TRY (GrB_Vector_build (d_15, I, f15, n, NULL)) ;
+     532             : 
+     533           2 :             free (neighbors) ;
+     534           2 :             free (k4cmn) ;
+     535           2 :             free (f15) ;
+     536           2 :             free (I) ;
+     537           2 :             free (isNeighbor) ;
+     538             :         }
+     539             : 
+     540             :     }
+     541             : 
+     542             :     //--------------------------------------------------------------------------
+     543             :     // construct raw frequencies matrix F_raw
+     544             :     //--------------------------------------------------------------------------
+     545             : 
+     546           2 :     GRB_TRY (GrB_Matrix_new (&F_raw, GrB_INT64, 16, n)) ;
+     547             : 
+     548           2 :     GrB_Vector d[16] = {d_0, d_1, d_2, d_3, d_4, d_5, d_6, d_7, d_8, d_9, d_10, d_11, d_12, d_13, d_14, d_15} ;
+     549             : 
+     550          34 :     for (int i = 0; i < 15 + (compute_d_15 ? 1 : 0); ++i) {
+     551          32 :         GRB_TRY (GrB_Vector_nvals (&nvals, d[i]));
+     552             : 
+     553          32 :         GrB_Index *J = (GrB_Index*) malloc (nvals*sizeof(GrB_Index)) ;
+     554          32 :         int64_t *vals = (int64_t*) malloc (nvals*sizeof(int64_t)) ;
+     555             : 
+     556          32 :         GRB_TRY (GrB_Vector_extractTuples (J, vals, &nvals, d[i])) ;
+     557         678 :         for (int j = 0; j < nvals; ++j) {
+     558         646 :             GRB_TRY (GrB_Matrix_setElement (F_raw, vals[j], i, J[j])) ;
+     559             :         }
+     560             : 
+     561          32 :         free (J) ;
+     562          32 :         free (vals) ;
+     563             :     }
+     564             : 
+     565             :     //--------------------------------------------------------------------------
+     566             :     // construct U_inv
+     567             :     //--------------------------------------------------------------------------
+     568             : 
+     569           2 :     GRB_TRY (GrB_Matrix_new (&U_inv, GrB_INT64, 16, 16)) ;
+     570             : 
+     571           2 :     GRB_TRY (GrB_Matrix_build (U_inv, U_inv_I, U_inv_J, U_inv_X, U_inv_nvals, GrB_PLUS_INT64)) ;
+     572             :     //GRB_TRY (GxB_print (U_inv, 3)) ;
+     573             : 
+     574             :     //--------------------------------------------------------------------------
+     575             :     // construct net frequencies matrix F_net
+     576             :     //--------------------------------------------------------------------------
+     577             : 
+     578           2 :     GRB_TRY (GrB_Matrix_new (F_net, GrB_INT64, 16, n)) ;
+     579             : 
+     580           2 :     GRB_TRY (GrB_mxm (*F_net, NULL, NULL, GxB_PLUS_TIMES_INT64, U_inv, F_raw, NULL)) ;
+     581             : 
+     582           2 :     GrB_Vector f_net = NULL ;
+     583           2 :     GRB_TRY (GrB_Vector_new (&f_net, GrB_INT64, 16)) ;
+     584           2 :     GRB_TRY (GrB_reduce (f_net, NULL, NULL, GrB_PLUS_INT64, *F_net, NULL)) ;
+     585           2 :     GRB_TRY (GxB_print (f_net, 3)) ;
+     586           2 :     GRB_TRY (GrB_free (&f_net)) ;
+     587             :     //GRB_TRY (GxB_print (*F_net, 3)) ;
+     588             : 
+     589             :     //--------------------------------------------------------------------------
+     590             :     // free work
+     591             :     //--------------------------------------------------------------------------
+     592             : 
+     593           8 :     LG_FREE_WORK ;
+     594           2 :     free ((void *) A_Tiles) ;       A_Tiles = NULL ;
+     595           2 :     free ((void *) D_Tiles) ;       D_Tiles = NULL ;
+     596           2 :     free ((void *) C_Tiles) ;       C_Tiles = NULL ;
+     597           2 :     free ((void *) Tile_nrows) ;    Tile_nrows = NULL ;
+     598             : 
+     599           2 :     return (0) ;
+     600             : #endif
+     601             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_HelloWorld.c.func-sort-c.html b/experimental/algorithm/LAGraph_HelloWorld.c.func-sort-c.html new file mode 100644 index 0000000000..80507c9825 --- /dev/null +++ b/experimental/algorithm/LAGraph_HelloWorld.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_HelloWorld.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_HelloWorld.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1212100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_HelloWorld1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_HelloWorld.c.func.html b/experimental/algorithm/LAGraph_HelloWorld.c.func.html new file mode 100644 index 0000000000..a505cfdf38 --- /dev/null +++ b/experimental/algorithm/LAGraph_HelloWorld.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_HelloWorld.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_HelloWorld.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1212100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_HelloWorld1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_HelloWorld.c.gcov.html b/experimental/algorithm/LAGraph_HelloWorld.c.gcov.html new file mode 100644 index 0000000000..6ae674216d --- /dev/null +++ b/experimental/algorithm/LAGraph_HelloWorld.c.gcov.html @@ -0,0 +1,175 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_HelloWorld.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_HelloWorld.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1212100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_HelloWorld: a nearly empty algorithm
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // This is a bare-bones "algorithm" that does nearly nothing all.  It simply
+      19             : // illustrates how a new algorithm can be added to the experimental/algorithm
+      20             : // folder.  All it does is make a copy of the G->A matrix and return it as
+      21             : // the new matrix Y.  Inside, it allocates some worspace as well (the matrix W,
+      22             : // which is not used).  To illustrate the use of the error msg string, it
+      23             : // returns an error if the graph not directed.
+      24             : 
+      25             : // The GRB_TRY and LG_TRY macros use the LG_FREE_ALL macro to free all
+      26             : // workspace and all output variables if an error occurs.  To use these macros,
+      27             : // you must define the variables before using them, or before using GRB_TRY
+      28             : // or LG_TRY.  The LG_TRY macro is defined in src/utility/LG_internal.h.
+      29             : 
+      30             : // To create your own algorithm, create a copy of this file, rename it
+      31             : // to LAGraph_whatever.c, and use it as a template for your own algorithm.
+      32             : // Then place the prototype in include/LAGraphX.h.
+      33             : 
+      34             : // See experimental/test/test_HelloWorld.c for a test for this method, and
+      35             : // experimental/benchmark/helloworld_demo.c and helloworld2_demo.c for two
+      36             : // methods that benchmark the performance of this algorithm.
+      37             : 
+      38             : #define LG_FREE_WORK                        \
+      39             : {                                           \
+      40             :     /* free any workspace used here */      \
+      41             :     GrB_free (&W) ;                         \
+      42             : }
+      43             : 
+      44             : #define LG_FREE_ALL                         \
+      45             : {                                           \
+      46             :     /* free any workspace used here */      \
+      47             :     LG_FREE_WORK ;                          \
+      48             :     /* free all the output variable(s) */   \
+      49             :     GrB_free (&Y) ;                         \
+      50             :     /* take any other corrective action */  \
+      51             : }
+      52             : 
+      53             : #include "LG_internal.h"
+      54             : #include "LAGraphX.h"
+      55             : 
+      56           1 : int LAGraph_HelloWorld // a simple algorithm, just for illustration
+      57             : (
+      58             :     // output
+      59             :     GrB_Matrix *Yhandle,    // Y, created on output
+      60             :     // input: not modified
+      61             :     LAGraph_Graph G,
+      62             :     char *msg
+      63             : )
+      64             : {
+      65             : 
+      66             :     //--------------------------------------------------------------------------
+      67             :     // check inputs
+      68             :     //--------------------------------------------------------------------------
+      69             : 
+      70           1 :     GrB_Matrix W = NULL, Y = NULL ;     // declare workspace and output(s)
+      71           1 :     LG_CLEAR_MSG ;                      // clears the msg string, if not NULL
+      72             : 
+      73             :     // the caller must pass in a non-NULL &Y on input
+      74           1 :     LG_ASSERT (Yhandle != NULL, GrB_NULL_POINTER) ;
+      75           1 :     (*Yhandle) = NULL ;
+      76             : 
+      77             :     // basic checks of the input graph
+      78           1 :     LG_TRY (LAGraph_CheckGraph (G, msg)) ;
+      79             : 
+      80             :     // the graph must be directed (a useless test, just to illustrate
+      81             :     // the use of the LG_ASSERT_MSG macro)
+      82           1 :     LG_ASSERT_MSG (G->kind == LAGraph_ADJACENCY_DIRECTED,
+      83             :         GrB_INVALID_VALUE, "LAGraph_HelloWorld requires a directed graph") ;
+      84             : 
+      85             :     //--------------------------------------------------------------------------
+      86             :     // allocate workspace and create the output matrix Y
+      87             :     //--------------------------------------------------------------------------
+      88             : 
+      89           1 :     GRB_TRY (GrB_Matrix_new (&W, GrB_FP32, 5, 5)) ;     // useless workspace
+      90           1 :     GRB_TRY (GrB_Matrix_dup (&Y, G->A)) ;
+      91             : 
+      92             :     //--------------------------------------------------------------------------
+      93             :     // free workspace and return result
+      94             :     //--------------------------------------------------------------------------
+      95             : 
+      96           1 :     LG_FREE_WORK ;
+      97           1 :     (*Yhandle) = Y ;
+      98           1 :     return (GrB_SUCCESS) ;
+      99             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_KCore.c.func-sort-c.html b/experimental/algorithm/LAGraph_KCore.c.func-sort-c.html new file mode 100644 index 0000000000..df20106fdc --- /dev/null +++ b/experimental/algorithm/LAGraph_KCore.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_KCore.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_KCore.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:4444100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_KCore8
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_KCore.c.func.html b/experimental/algorithm/LAGraph_KCore.c.func.html new file mode 100644 index 0000000000..d52f1a8995 --- /dev/null +++ b/experimental/algorithm/LAGraph_KCore.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_KCore.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_KCore.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:4444100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_KCore8
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_KCore.c.gcov.html b/experimental/algorithm/LAGraph_KCore.c.gcov.html new file mode 100644 index 0000000000..607dcb952b --- /dev/null +++ b/experimental/algorithm/LAGraph_KCore.c.gcov.html @@ -0,0 +1,213 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_KCore.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_KCore.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:4444100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_KCore: Single K-core Decomposition Using the GraphBLAS API
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Pranav Konduri, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #define LG_FREE_WORK                \
+      19             : {                                   \
+      20             :     GrB_free (&deg) ;               \
+      21             :     GrB_free (&q) ;                 \
+      22             :     GrB_free (&delta) ;             \
+      23             :     GrB_free (&done) ;              \
+      24             : }
+      25             : 
+      26             : #define LG_FREE_ALL                 \
+      27             : {                                   \
+      28             :     LG_FREE_WORK                    \
+      29             :     GrB_free (decomp) ;             \
+      30             : }
+      31             : 
+      32             : #include "LG_internal.h"
+      33             : 
+      34             : 
+      35           8 : int LAGraph_KCore
+      36             : (
+      37             :     // outputs:
+      38             :     GrB_Vector *decomp,     // kcore decomposition
+      39             :     // inputs:
+      40             :     LAGraph_Graph G,        // input graph
+      41             :     uint64_t k,             //k level to compare to
+      42             :     char *msg
+      43             : )
+      44             : {
+      45           8 :     LG_CLEAR_MSG ;
+      46             : 
+      47             :     // declare items
+      48           8 :     GrB_Matrix A = NULL;
+      49           8 :     GrB_Vector deg = NULL, q = NULL, done = NULL, delta = NULL;
+      50             : 
+      51           8 :     LG_ASSERT (decomp != NULL, GrB_NULL_POINTER) ;
+      52           7 :     (*decomp) = NULL ;
+      53             : 
+      54           7 :     LG_TRY (LAGraph_CheckGraph (G, msg)) ;
+      55             : 
+      56           6 :     if (G->kind == LAGraph_ADJACENCY_UNDIRECTED ||
+      57           3 :        (G->kind == LAGraph_ADJACENCY_DIRECTED &&
+      58           3 :         G->is_symmetric_structure == LAGraph_TRUE))
+      59             :     {
+      60             :          // the structure of A is known to be symmetric
+      61           5 :         A = G->A ;
+      62             :     }
+      63             :     else
+      64             :     {
+      65             :         // A is not known to be symmetric
+      66           1 :         LG_ASSERT_MSG (false, -1005, "G->A must be symmetric") ;
+      67             :     }
+      68             : 
+      69             :     // no self edges can be present
+      70           5 :     LG_ASSERT_MSG (G->nself_edges == 0, -1004, "G->nself_edges must be zero") ;
+      71             : 
+      72             :     //create work scalars
+      73             :     GrB_Index n, qnvals, degnvals, maxDeg;
+      74           4 :     GRB_TRY (GrB_Matrix_nrows(&n, A)) ;
+      75             : 
+      76             :     //create deg vector using rowdegree property
+      77           4 :     LG_TRY (LAGraph_Cached_OutDegree(G, msg)) ;
+      78           4 :     GRB_TRY (GrB_Vector_dup(&deg, G->out_degree)) ; //original deg vector is technically 1-core since 0 is omitted
+      79           4 :     GRB_TRY (GrB_Vector_nvals(&degnvals, deg)) ;
+      80             : 
+      81             :     //retrieve the max degree level of the graph
+      82           4 :     GRB_TRY (GrB_reduce(&maxDeg, GrB_NULL, GrB_MAX_MONOID_INT64, G->out_degree, GrB_NULL)) ;
+      83             : 
+      84             :     //select int type for work vectors and semirings
+      85           4 :     GrB_Type int_type  = (maxDeg > INT32_MAX) ? GrB_INT64 : GrB_INT32 ;
+      86             : 
+      87           4 :     GRB_TRY (GrB_Vector_new(&q, int_type, n));
+      88           4 :     GRB_TRY (GrB_Vector_new(&done, GrB_BOOL, n)) ;
+      89           4 :     GRB_TRY (GrB_Vector_new(&delta, int_type, n)) ;
+      90             :     //set output to int64
+      91           4 :     GRB_TRY (GrB_Vector_new(decomp, int_type, n)) ;
+      92             : 
+      93             :     //change deg vector to int32 if needed
+      94           4 :     if(int_type == GrB_INT32){
+      95           4 :         GRB_TRY (GrB_Vector_new(&deg, int_type, n)) ;
+      96           4 :         GRB_TRY (GrB_assign (deg, G->out_degree, NULL, G->out_degree, GrB_ALL, n, NULL)) ;
+      97             :     }
+      98             : 
+      99             :     // determine semiring types
+     100           4 :     GrB_IndexUnaryOp valueLT = (maxDeg > INT32_MAX) ? GrB_VALUELT_INT64 : GrB_VALUELT_INT32 ;
+     101           4 :     GrB_BinaryOp minus_op = (maxDeg > INT32_MAX) ? GrB_MINUS_INT64 : GrB_MINUS_INT32 ;
+     102           4 :     GrB_Semiring semiring = (maxDeg > INT32_MAX) ? LAGraph_plus_one_int64 : LAGraph_plus_one_int32 ;
+     103             : 
+     104             : 
+     105             : #if LG_SUITESPARSE
+     106             :     GRB_TRY (GxB_set (done, GxB_SPARSITY_CONTROL, GxB_BITMAP + GxB_FULL)) ;    // try this
+     107             :     //GRB_TRY (GxB_set (*decomp, GxB_SPARSITY_CONTROL, GxB_BITMAP + GxB_FULL)) ; // try this ... likely not needed
+     108             : #endif
+     109             : 
+     110             :     // Creating q
+     111           4 :     GRB_TRY (GrB_select (q, GrB_NULL, GrB_NULL, valueLT, deg, k, GrB_NULL)) ; // get all nodes with degree = level
+     112           4 :     GRB_TRY (GrB_Vector_nvals(&qnvals, q));
+     113             : 
+     114             :     // while q not empty
+     115           4 :     int round = 0;
+     116          10 :     while(qnvals > 0 && degnvals > 0){
+     117           6 :         round++;
+     118             :         //add anything in q as true into the done list
+     119           6 :         GRB_TRY (GrB_assign (done, q, NULL, (bool) true, GrB_ALL, n, GrB_DESC_S)) ; //structure to take care of 0-node cases
+     120             : 
+     121             :         // Create delta (the nodes who lost friends, and how many they lost) (push version)
+     122           6 :         GRB_TRY (GrB_vxm (delta, GrB_NULL, GrB_NULL, semiring, q, A, GrB_NULL));
+     123             : 
+     124             :         // Create new deg vector (keep anything not in done vector)
+     125           6 :         GRB_TRY (GrB_eWiseAdd(deg, done, GrB_NULL, minus_op, deg, delta, GrB_DESC_RSC)) ;
+     126             : 
+     127             :         // Update q, set new nvals
+     128           6 :         GRB_TRY (GrB_select (q, GrB_NULL, GrB_NULL, valueLT, deg, k, GrB_NULL)) ;
+     129           6 :         GRB_TRY (GrB_Vector_nvals(&qnvals, q)) ;
+     130           6 :         GRB_TRY (GrB_Vector_nvals(&degnvals, deg)) ;
+     131             :     }
+     132             :     //Assign values of deg to decomp
+     133           4 :     GRB_TRY (GrB_assign (*decomp, deg, NULL, k, GrB_ALL, n, GrB_NULL)) ;
+     134           4 :     GRB_TRY(GrB_Vector_wait(*decomp, GrB_MATERIALIZE));
+     135           4 :     LG_FREE_WORK ;
+     136           4 :     return (GrB_SUCCESS) ;
+     137             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_KCoreDecompose.c.func-sort-c.html b/experimental/algorithm/LAGraph_KCoreDecompose.c.func-sort-c.html new file mode 100644 index 0000000000..66c94e8131 --- /dev/null +++ b/experimental/algorithm/LAGraph_KCoreDecompose.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_KCoreDecompose.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_KCoreDecompose.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:2525100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_KCore_Decompose6
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_KCoreDecompose.c.func.html b/experimental/algorithm/LAGraph_KCoreDecompose.c.func.html new file mode 100644 index 0000000000..66efa4ffe9 --- /dev/null +++ b/experimental/algorithm/LAGraph_KCoreDecompose.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_KCoreDecompose.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_KCoreDecompose.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:2525100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_KCore_Decompose6
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_KCoreDecompose.c.gcov.html b/experimental/algorithm/LAGraph_KCoreDecompose.c.gcov.html new file mode 100644 index 0000000000..f15fa19553 --- /dev/null +++ b/experimental/algorithm/LAGraph_KCoreDecompose.c.gcov.html @@ -0,0 +1,192 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_KCoreDecompose.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_KCoreDecompose.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:2525100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_KCoreDecompose: Helper method to LAGraph_KCore and LAGraph_AllKCore
+       3             : // that performs graph decomposition given a specified value k.
+       4             : //------------------------------------------------------------------------------
+       5             : 
+       6             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       7             : // SPDX-License-Identifier: BSD-2-Clause
+       8             : //
+       9             : // For additional details (including references to third party source code and
+      10             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      11             : // Contributors.txt for a full list of contributors. Created, in part, with
+      12             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      13             : // DM22-0790
+      14             : 
+      15             : // Contributed by Pranav Konduri, Texas A&M University
+      16             : 
+      17             : //------------------------------------------------------------------------------
+      18             : 
+      19             : #define LG_FREE_WORK                \
+      20             : {                                   \
+      21             :     GrB_free (&C) ;                 \
+      22             :     GrB_free (&deg) ;               \
+      23             : }
+      24             : 
+      25             : #define LG_FREE_ALL                 \
+      26             : {                                   \
+      27             :     LG_FREE_WORK                    \
+      28             :     GrB_free (D) ;                  \
+      29             : }
+      30             : 
+      31             : #include "LG_internal.h"
+      32             : 
+      33             : 
+      34           6 : int LAGraph_KCore_Decompose
+      35             : (
+      36             :     // outputs:
+      37             :     GrB_Matrix *D,              // kcore decomposition
+      38             :     // inputs:
+      39             :     LAGraph_Graph G,            // input graph
+      40             :     GrB_Vector decomp,         // input decomposition matrix
+      41             :     uint64_t k,
+      42             :     char *msg
+      43             : )
+      44             : {
+      45           6 :     LG_CLEAR_MSG ;
+      46             : 
+      47             :     // declare items
+      48           6 :     GrB_Matrix A = NULL, C = NULL;
+      49           6 :     GrB_Vector deg = NULL;
+      50             : 
+      51             : 
+      52           6 :     LG_ASSERT (D != NULL, GrB_NULL_POINTER) ;
+      53           6 :     (*D) = NULL ;
+      54             : 
+      55             : #if !LAGRAPH_SUITESPARSE
+      56             :     LG_ASSERT (false, GrB_NOT_IMPLEMENTED) ;
+      57             : #else
+      58             : 
+      59           6 :     LG_TRY (LAGraph_CheckGraph (G, msg)) ;
+      60             : 
+      61           5 :     if (G->kind == LAGraph_ADJACENCY_UNDIRECTED ||
+      62           2 :        (G->kind == LAGraph_ADJACENCY_DIRECTED &&
+      63           2 :         G->is_symmetric_structure == LAGraph_TRUE))
+      64             :     {
+      65             :          // the structure of A is known to be symmetric
+      66           4 :         A = G->A ;
+      67             :     }
+      68             :     else
+      69             :     {
+      70             :         // A is not known to be symmetric
+      71           1 :         LG_ASSERT_MSG (false, -1005, "G->A must be symmetric") ;
+      72             :     }
+      73             : 
+      74             :     // no self edges can be present
+      75             :     // todo: what would happen if there are self edges?
+      76           4 :     LG_ASSERT_MSG (G->nself_edges == 0, -1004, "G->nself_edges must be zero") ;
+      77             : 
+      78             :     //create work scalars
+      79             :     GrB_Index nrows, n;
+      80           3 :     GRB_TRY (GrB_Matrix_nrows(&nrows, A)) ;
+      81           3 :     GRB_TRY (GrB_Vector_size(&n, decomp)) ;
+      82           2 :     LG_ASSERT_MSG (nrows == n, -1003, "Size of vector and rows of matrix must be same") ;
+      83             : 
+      84             :     //Create Vectors and Matrices
+      85           2 :     GRB_TRY (GrB_Vector_new(&deg, GrB_INT64, n)) ;
+      86           2 :     GRB_TRY (GrB_Matrix_new(D, GrB_INT64, n, n)) ;
+      87             : 
+      88             :     //create deg vector using select
+      89           2 :     GRB_TRY (GrB_select (deg, GrB_NULL, GrB_NULL, GrB_VALUEGE_INT64, decomp, k, GrB_NULL)) ;
+      90             : 
+      91             :     //create decomposition matrix (C * A * C)
+      92             : 
+      93             :     #if LAGRAPH_SUITESPARSE
+      94             :         #if GxB_IMPLEMENTATION >= GxB_VERSION (7,0,0)
+      95             :         // SuiteSparse 7.x and later:
+      96           2 :         GRB_TRY (GrB_Matrix_diag(&C, deg, 0)) ;
+      97             :         #else
+      98             :         // SuiteSparse 6.x and earlier, which had the incorrect signature:
+      99             :         GRB_TRY (GrB_Matrix_new(&C, GrB_INT64, n, n)) ;
+     100             :         GRB_TRY (GrB_Matrix_diag(C, deg, 0)) ;
+     101             :         #endif
+     102             :     #else
+     103             :     // standard GrB:
+     104             :     GRB_TRY (GrB_Matrix_diag(&C, deg, 0)) ;
+     105             :     #endif
+     106             : 
+     107           2 :     GRB_TRY (GrB_mxm (*D, NULL, NULL, GxB_ANY_SECONDI_INT64, C, A, GrB_NULL)) ;
+     108           2 :     GRB_TRY (GrB_mxm (*D, NULL, NULL, GxB_MIN_SECONDI_INT64, *D, C, GrB_NULL)) ;
+     109             : 
+     110             :     //Assigns all values as 1 (todo: change to something cleaner)
+     111           2 :     GRB_TRY (GrB_assign (*D, *D, NULL, (int64_t) 1, GrB_ALL, n, GrB_ALL, n, GrB_DESC_S)) ;
+     112             : 
+     113           2 :     LG_FREE_WORK ;
+     114           2 :     return (GrB_SUCCESS) ;
+     115             : #endif
+     116             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_KTruss.c.func-sort-c.html b/experimental/algorithm/LAGraph_KTruss.c.func-sort-c.html new file mode 100644 index 0000000000..bdcc8c61d0 --- /dev/null +++ b/experimental/algorithm/LAGraph_KTruss.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_KTruss.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_KTruss.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:2424100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_KTruss84
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_KTruss.c.func.html b/experimental/algorithm/LAGraph_KTruss.c.func.html new file mode 100644 index 0000000000..973d2014de --- /dev/null +++ b/experimental/algorithm/LAGraph_KTruss.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_KTruss.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_KTruss.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:2424100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_KTruss84
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_KTruss.c.gcov.html b/experimental/algorithm/LAGraph_KTruss.c.gcov.html new file mode 100644 index 0000000000..4746f09bf6 --- /dev/null +++ b/experimental/algorithm/LAGraph_KTruss.c.gcov.html @@ -0,0 +1,190 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_KTruss.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_KTruss.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:2424100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_KTruss: k-truss subgraph
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // LAGraph_KTruss: k-truss subgraph.
+      19             : 
+      20             : // Given a symmetric graph A with no-self edges, LAGraph_KTruss finds the
+      21             : // k-truss subgraph of A.
+      22             : 
+      23             : // The graph G must be undirected, or have an adjacency matrix with symmetric
+      24             : // structure.  Only the structure of G->A is considered.  Its values are
+      25             : // ignored.  G must not have any self-edges.
+      26             : 
+      27             : // The output matrix C is the k-truss subgraph of A.  Its edges are a subset of
+      28             : // G->A.  Each edge in C is part of at least k-2 triangles in C.  The structure
+      29             : // of C is the adjacency matrix of the k-truss subgraph of A.  The edge weights
+      30             : // of C are the support of each edge.  That is, C(i,j)=nt if the edge (i,j) is
+      31             : // part of nt triangles in C.  All edges in C have support of at least k-2.
+      32             : // The total number of triangles in C is sum(C)/6.  C is returned as symmetric
+      33             : // with a zero-free diagonal.
+      34             : 
+      35             : #define LG_FREE_ALL GrB_free (&C) ;
+      36             : #include "LG_internal.h"
+      37             : #include "LAGraphX.h"
+      38             : 
+      39             : //------------------------------------------------------------------------------
+      40             : // LAGraph_KTruss: find the k-truss subgraph of a graph
+      41             : //------------------------------------------------------------------------------
+      42             : 
+      43          84 : int LAGraph_KTruss              // compute the k-truss of a graph
+      44             : (
+      45             :     // outputs:
+      46             :     GrB_Matrix *C_handle,       // output k-truss subgraph, C
+      47             :     // inputs:
+      48             :     LAGraph_Graph G,            // input graph
+      49             :     uint32_t k,                 // find the k-truss, where k >= 3
+      50             :     char *msg
+      51             : )
+      52             : {
+      53             : 
+      54             :     //--------------------------------------------------------------------------
+      55             :     // check inputs
+      56             :     //--------------------------------------------------------------------------
+      57             : 
+      58          84 :     LG_CLEAR_MSG ;
+      59          84 :     GrB_Matrix C = NULL ;
+      60          84 :     LG_ASSERT (C_handle != NULL, GrB_NULL_POINTER) ;
+      61          83 :     (*C_handle) = NULL ;
+      62          83 :     LG_ASSERT_MSG (k >= 3, GrB_INVALID_VALUE, "k invalid") ;
+      63          82 :     LG_TRY (LAGraph_CheckGraph (G, msg)) ;
+      64             : 
+      65          81 :     if (G->kind == LAGraph_ADJACENCY_UNDIRECTED ||
+      66           9 :        (G->kind == LAGraph_ADJACENCY_DIRECTED &&
+      67           9 :         G->is_symmetric_structure == LAGraph_TRUE))
+      68             :     {
+      69             :         // the structure of A is known to be symmetric
+      70             :         ;
+      71             :     }
+      72             :     else
+      73             :     {
+      74             :         // A is not known to be symmetric
+      75           1 :         LG_ASSERT_MSG (false, -1005, "G->A must be symmetric") ;
+      76             :     }
+      77             : 
+      78             :     // no self edges can be present
+      79          80 :     LG_ASSERT_MSG (G->nself_edges == 0, -1004, "G->nself_edges must be zero") ;
+      80             : 
+      81             :     //--------------------------------------------------------------------------
+      82             :     // initializations
+      83             :     //--------------------------------------------------------------------------
+      84             : 
+      85             :     GrB_Index n ;
+      86          79 :     GrB_Matrix S = G->A ;
+      87          79 :     GRB_TRY (GrB_Matrix_nrows (&n, S)) ;
+      88          79 :     GRB_TRY (GrB_Matrix_new (&C, GrB_UINT32, n, n)) ;
+      89             :     GrB_Index nvals, nvals_last ;
+      90          79 :     GRB_TRY (GrB_Matrix_nvals (&nvals_last, S)) ;
+      91             : 
+      92             :     //--------------------------------------------------------------------------
+      93             :     // find the k-truss of G->A
+      94             :     //--------------------------------------------------------------------------
+      95             : 
+      96             :     while (true)
+      97             :     {
+      98             :         // C{S} = S*S'
+      99         327 :         GRB_TRY (GrB_mxm (C, S, NULL, LAGraph_plus_one_uint32, S, S,
+     100             :             GrB_DESC_RST1)) ;
+     101             :         // keep entries in C that are >= k-2
+     102         327 :         GRB_TRY (GrB_select (C, NULL, NULL, GrB_VALUEGE_UINT32, C, k-2, NULL)) ;
+     103             :         // return if the k-truss has been found
+     104         327 :         GRB_TRY (GrB_Matrix_nvals (&nvals, C)) ;
+     105         327 :         if (nvals == nvals_last)
+     106             :         {
+     107          79 :             (*C_handle) = C ;
+     108          79 :             return (GrB_SUCCESS) ;
+     109             :         }
+     110             :         // advance to the next step
+     111         248 :         nvals_last = nvals ;
+     112         248 :         S = C ;
+     113             :     }
+     114             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_MaximalIndependentSet.c.func-sort-c.html b/experimental/algorithm/LAGraph_MaximalIndependentSet.c.func-sort-c.html new file mode 100644 index 0000000000..2251c670af --- /dev/null +++ b/experimental/algorithm/LAGraph_MaximalIndependentSet.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_MaximalIndependentSet.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_MaximalIndependentSet.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:8181100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_MaximalIndependentSet368
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_MaximalIndependentSet.c.func.html b/experimental/algorithm/LAGraph_MaximalIndependentSet.c.func.html new file mode 100644 index 0000000000..33ccd7d4fc --- /dev/null +++ b/experimental/algorithm/LAGraph_MaximalIndependentSet.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_MaximalIndependentSet.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_MaximalIndependentSet.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:8181100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_MaximalIndependentSet368
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_MaximalIndependentSet.c.gcov.html b/experimental/algorithm/LAGraph_MaximalIndependentSet.c.gcov.html new file mode 100644 index 0000000000..4bd524cf85 --- /dev/null +++ b/experimental/algorithm/LAGraph_MaximalIndependentSet.c.gcov.html @@ -0,0 +1,391 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_MaximalIndependentSet.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_MaximalIndependentSet.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:8181100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_MaximalIndependentSet: maximal independent set, with constraints
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Modified from the GraphBLAS C API Specification, by Aydin Buluc, Timothy
+      15             : // Mattson, Scott McMillan, Jose' Moreira, Carl Yang.  Based on "GraphBLAS
+      16             : // Mathematics" by Jeremy Kepner.  Revised by Timothy A. Davis, Texas A&M
+      17             : // University.
+      18             : 
+      19             : //------------------------------------------------------------------------------
+      20             : 
+      21             : #define LG_FREE_WORK                \
+      22             : {                                   \
+      23             :     GrB_free (&neighbor_max) ;      \
+      24             :     GrB_free (&new_members) ;       \
+      25             :     GrB_free (&new_neighbors) ;     \
+      26             :     GrB_free (&candidates) ;        \
+      27             :     GrB_free (&empty) ;             \
+      28             :     GrB_free (&Seed) ;              \
+      29             :     GrB_free (&score) ;             \
+      30             :     GrB_free (&degree) ;            \
+      31             : }
+      32             : 
+      33             : #define LG_FREE_ALL                 \
+      34             : {                                   \
+      35             :     LG_FREE_WORK ;                  \
+      36             :     GrB_free (&iset) ;              \
+      37             : }
+      38             : 
+      39             : #include "LG_internal.h"
+      40             : #include "LAGraphX.h"
+      41             : 
+      42             : // A variant of Luby's randomized algorithm [Luby 1985].
+      43             : 
+      44             : // Given a numeric n x n adjacency matrix A of an unweighted and undirected
+      45             : // graph (where the value true represents an edge), compute a maximal set of
+      46             : // independent nodes and return it in a boolean n-vector, mis where
+      47             : // mis[i] == true implies node i is a member of the set.
+      48             : 
+      49             : // The graph cannot have any self edges, and it must be symmetric.  Self-edges
+      50             : // (diagonal entries) will cause the method to stall, and thus G->nself_edges
+      51             : // must be zero on input.  G->out_degree must be present on input.  It must not
+      52             : // contain any explicit zeros (this is handled by LAGraph_Cached_OutDegree).
+      53             : 
+      54             : // Singletons require special treatment.  Since they have no neighbors, their
+      55             : // score is never greater than the max of their neighbors, so they never get
+      56             : // selected and cause the method to stall.  To avoid this case they are removed
+      57             : // from the candidate set at the begining, and added to the independent set.
+      58             : 
+      59         368 : int LAGraph_MaximalIndependentSet       // maximal independent set
+      60             : (
+      61             :     // outputs:
+      62             :     GrB_Vector *mis,            // mis(i) = true if i is in the set
+      63             :     // inputs:
+      64             :     LAGraph_Graph G,            // input graph
+      65             :     uint64_t seed,              // random number seed
+      66             :     GrB_Vector ignore_node,     // if NULL, no nodes are ignored.  Otherwise
+      67             :                                 // ignore_node(i) = true if node i is to be
+      68             :                                 // ignored, and not treated as a candidate
+      69             :                                 // added to maximal independent set.
+      70             :     char *msg
+      71             : )
+      72             : {
+      73             : 
+      74             :     //--------------------------------------------------------------------------
+      75             :     // check inputs
+      76             :     //--------------------------------------------------------------------------
+      77             : 
+      78         368 :     LG_CLEAR_MSG ;
+      79         368 :     GrB_Vector iset = NULL ;            // independent set (output vector)
+      80         368 :     GrB_Vector score = NULL ;           // random score for each node
+      81         368 :     GrB_Vector neighbor_max = NULL ;    // value of max neighbor score
+      82         368 :     GrB_Vector new_members = NULL ;     // set of new members to add to iset
+      83         368 :     GrB_Vector new_neighbors = NULL ;   // new neighbors to new iset members
+      84         368 :     GrB_Vector candidates = NULL ;      // candidate nodes
+      85         368 :     GrB_Vector empty = NULL ;           // an empty vector
+      86         368 :     GrB_Vector Seed = NULL ;            // random number seed vector
+      87         368 :     GrB_Vector degree = NULL ;          // (float) G->out_degree
+      88             :     GrB_Matrix A ;                      // G->A, the adjacency matrix
+      89             :     GrB_Index n ;                       // # of nodes
+      90             : 
+      91         368 :     LG_TRY (LAGraph_CheckGraph (G, msg)) ;
+      92         368 :     LG_ASSERT (mis != NULL, GrB_NULL_POINTER) ;
+      93             : 
+      94         368 :     if (G->kind == LAGraph_ADJACENCY_UNDIRECTED ||
+      95          48 :        (G->kind == LAGraph_ADJACENCY_DIRECTED &&
+      96          48 :         G->is_symmetric_structure == LAGraph_TRUE))
+      97             :     {
+      98             :         // the structure of A is known to be symmetric
+      99         352 :         A = G->A ;
+     100             :     }
+     101             :     else
+     102             :     {
+     103             :         // A is not known to be symmetric
+     104          16 :         LG_ASSERT_MSG (false, -105, "G->A must be symmetric") ;
+     105             :     }
+     106             : 
+     107         352 :     LG_ASSERT_MSG (G->out_degree != NULL, -106,
+     108             :         "G->out_degree must be defined") ;
+     109         352 :     LG_ASSERT_MSG (G->nself_edges == 0, -107, "G->nself_edges must be zero") ;
+     110             : 
+     111             :     //--------------------------------------------------------------------------
+     112             :     // initializations
+     113             :     //--------------------------------------------------------------------------
+     114             : 
+     115         352 :     GRB_TRY (GrB_Matrix_nrows (&n, A)) ;
+     116         352 :     GRB_TRY (GrB_Vector_new (&neighbor_max, GrB_FP32, n)) ;
+     117         352 :     GRB_TRY (GrB_Vector_new (&degree, GrB_FP32, n)) ;
+     118         352 :     GRB_TRY (GrB_Vector_new (&new_members, GrB_BOOL, n)) ;
+     119         352 :     GRB_TRY (GrB_Vector_new (&new_neighbors, GrB_BOOL, n)) ;
+     120         352 :     GRB_TRY (GrB_Vector_new (&candidates, GrB_BOOL, n)) ;
+     121         352 :     GRB_TRY (GrB_Vector_new (&empty, GrB_BOOL, n)) ;
+     122         352 :     GRB_TRY (GrB_Vector_new (&Seed, GrB_UINT64, n)) ;
+     123         352 :     GRB_TRY (GrB_Vector_new (&score, GrB_FP32, n)) ;
+     124         352 :     GRB_TRY (GrB_Vector_new (&iset, GrB_BOOL, n)) ;
+     125             : 
+     126             :     // degree = (float) G->out_degree
+     127         352 :     GRB_TRY (GrB_assign (degree, NULL, NULL, G->out_degree, GrB_ALL, n, NULL)) ;
+     128             : 
+     129             :     //--------------------------------------------------------------------------
+     130             :     // remove singletons (nodes of degree zero) and handle ignore_node
+     131             :     //--------------------------------------------------------------------------
+     132             : 
+     133         352 :     GrB_Index nonsingletons = 0 ;
+     134         352 :     GRB_TRY (GrB_Vector_nvals (&nonsingletons, degree)) ;
+     135         352 :     if (nonsingletons == n)
+     136             :     {
+     137         160 :         if (ignore_node == NULL)
+     138             :         {
+     139             :             // all nodes have degree 1 or more; all nodes are candidates
+     140             :             // candidates (0:n-1) = true
+     141          80 :             GRB_TRY (GrB_assign (candidates, NULL, NULL, (bool) true, GrB_ALL,
+     142             :                 n, NULL)) ;
+     143             :             // Seed vector starts out dense
+     144             :             // Seed (0:n-1) = 0
+     145          80 :             GRB_TRY (GrB_assign (Seed, NULL, NULL, 0, GrB_ALL, n, NULL)) ;
+     146             :         }
+     147             :         else
+     148             :         {
+     149             :             // all nodes have degree 1 or more, but some nodes are to be
+     150             :             // ignored.  Use ignore_node as a valued mask.
+     151             :             // candidates<!ignore_node> = true
+     152          80 :             GRB_TRY (GrB_assign (candidates, ignore_node, NULL, (bool) true,
+     153             :                 GrB_ALL, n, GrB_DESC_C)) ;
+     154             :             // Seed vector starts out sparse
+     155             :             // Seed{candidates} = 0
+     156          80 :             GRB_TRY (GrB_assign (Seed, candidates, NULL, 0, GrB_ALL, n,
+     157             :                 GrB_DESC_S)) ;
+     158             :         }
+     159             :     }
+     160             :     else
+     161             :     {
+     162             :         // one or more singleton is present.
+     163             :         // candidates{degree} = 1
+     164         192 :         GRB_TRY (GrB_assign (candidates, degree, NULL, (bool) true,
+     165             :             GrB_ALL, n, GrB_DESC_S)) ;
+     166             :         // add all singletons to iset
+     167             :         // iset{!degree} = 1
+     168         192 :         GRB_TRY (GrB_assign (iset, degree, NULL, (bool) true, GrB_ALL, n,
+     169             :             GrB_DESC_SC)) ;
+     170         192 :         if (ignore_node != NULL)
+     171             :         {
+     172             :             // one or more singletons are present, and some nodes are to be
+     173             :             // ignored.  The candidates are all those nodes with degree > 0
+     174             :             // for which ignore_node(i) is false (or not present).  Delete
+     175             :             // any candidate i for which ignore_node(i) is true.  Use
+     176             :             // ignore_node as a valued mask.
+     177             :             // candidates<ignore_node> = empty
+     178          80 :             GRB_TRY (GrB_assign (candidates, ignore_node, NULL, empty,
+     179             :                 GrB_ALL, n, NULL)) ;
+     180             :             // Delete any ignored nodes from iset
+     181             :             // iset<ignore_node> = empty
+     182          80 :             GRB_TRY (GrB_assign (iset, ignore_node, NULL, empty,
+     183             :                 GrB_ALL, n, NULL)) ;
+     184             :         }
+     185             :         // Seed vector starts out sparse
+     186             :         // Seed{candidates} = 0
+     187         192 :         GRB_TRY (GrB_assign (Seed, candidates, NULL, 0, GrB_ALL, n,
+     188             :             GrB_DESC_S)) ;
+     189             :     }
+     190             : 
+     191             :     // create the random number seeds
+     192         352 :     LG_TRY (LAGraph_Random_Seed (Seed, seed, msg)) ;
+     193             : 
+     194             :     //--------------------------------------------------------------------------
+     195             :     // iterate while there are candidates to check
+     196             :     //--------------------------------------------------------------------------
+     197             : 
+     198         352 :     int nstall = 0 ;
+     199             :     GrB_Index ncandidates ;
+     200         352 :     GRB_TRY (GrB_Vector_nvals (&ncandidates, candidates)) ;
+     201         352 :     GrB_Index last_ncandidates = ncandidates ;
+     202         352 :     GrB_Index n1 = (GrB_Index) (0.04 * (double) n) ;
+     203         352 :     GrB_Index n2 = (GrB_Index) (0.10 * (double) n) ;
+     204             : 
+     205        1362 :     while (ncandidates > 0)
+     206             :     {
+     207             :         // compute the score for each node; scale the Seed by degree
+     208             :         // score = (float) Seed
+     209        1165 :         GRB_TRY (GrB_assign (score, NULL, NULL, Seed, GrB_ALL, n, NULL)) ;
+     210             :         // score = score / degree
+     211        1152 :         GRB_TRY (GrB_eWiseMult (score, NULL, NULL, GrB_DIV_FP32, score, degree,
+     212             :             NULL)) ;
+     213             : 
+     214             :         // compute the max score of all candidate neighbors (only candidates
+     215             :         // have a score, so non-candidate neighbors are excluded)
+     216             :         // neighbor_max{candidates,replace} = score * A
+     217        1152 :         GRB_TRY (GrB_Vector_nvals (&ncandidates, candidates)) ;
+     218        1152 :         if (ncandidates < n1)
+     219             :         {
+     220             :             // push
+     221             :             // neighbor_max'{candidates,replace} = score' * A
+     222          84 :             GRB_TRY (GrB_vxm (neighbor_max, candidates, NULL,
+     223             :                 GrB_MAX_FIRST_SEMIRING_FP32, score, A, GrB_DESC_RS)) ;
+     224             :         }
+     225             :         else
+     226             :         {
+     227             :             // pull
+     228             :             // neighbor_max{candidates,replace} = A * score
+     229        1068 :             GRB_TRY (GrB_mxv (neighbor_max, candidates, NULL,
+     230             :                 GrB_MAX_SECOND_SEMIRING_FP32, A, score, GrB_DESC_RS)) ;
+     231             :         }
+     232             : 
+     233             :         // select node if its score is > than all its active neighbors
+     234             :         // new_members = (score > neighbor_max) using set union so that nodes
+     235             :         // with no neighbors fall through to the output, as true (since no
+     236             :         // score is equal to zero).
+     237        1152 :         GRB_TRY (GrB_eWiseAdd (new_members, NULL, NULL, GrB_GT_FP32,
+     238             :             score, neighbor_max, NULL)) ;
+     239             : 
+     240             :         // drop explicit zeros from new_members
+     241        1152 :         GRB_TRY (GrB_select (new_members, NULL, NULL, GrB_VALUEEQ_BOOL,
+     242             :             new_members, (bool) true, NULL)) ;
+     243             : 
+     244             :         // add new members to independent set
+     245             :         // iset{new_members} = true
+     246        1152 :         GRB_TRY (GrB_assign (iset, new_members, NULL, (bool) true,
+     247             :             GrB_ALL, n, GrB_DESC_S)) ;
+     248             : 
+     249             :         // remove new members from set of candidates
+     250             :         // candidates{new_members} = empty
+     251        1152 :         GRB_TRY (GrB_assign (candidates, new_members, NULL, empty,
+     252             :             GrB_ALL, n, GrB_DESC_S)) ;
+     253             : 
+     254             :         // early exit if candidates is empty
+     255        1152 :         GRB_TRY (GrB_Vector_nvals (&ncandidates, candidates)) ;
+     256        1152 :         if (ncandidates == 0) { break ; }
+     257             : 
+     258             :         // Neighbors of new members can also be removed from candidates
+     259             :         // new_neighbors{candidates,replace} = new_members * A
+     260             :         GrB_Index n_new_members ;
+     261        1023 :         GRB_TRY (GrB_Vector_nvals (&n_new_members, new_members)) ;
+     262        1023 :         if (n_new_members < n2)
+     263             :         {
+     264             :             // push
+     265             :             // new_neighbors{candidates,replace} = new_members' * A
+     266         388 :             GRB_TRY (GrB_vxm (new_neighbors, candidates, NULL,
+     267             :                 LAGraph_any_one_bool, new_members, A, GrB_DESC_RS)) ;
+     268             :         }
+     269             :         else
+     270             :         {
+     271             :             // pull
+     272             :             // new_neighbors{candidates,replace} = A * new_members
+     273         635 :             GRB_TRY (GrB_mxv (new_neighbors, candidates, NULL,
+     274             :                 LAGraph_any_one_bool, A, new_members, GrB_DESC_RS)) ;
+     275             :         }
+     276             : 
+     277             :         // remove new neighbors of new members from set of candidates
+     278             :         // candidates{new_neighbors} = empty
+     279        1023 :         GRB_TRY (GrB_assign (candidates, new_neighbors, NULL, empty,
+     280             :             GrB_ALL, n, GrB_DESC_S)) ;
+     281             : 
+     282             :         // sparsify the random number seeds (just keep it for each candidate)
+     283             :         // Seed{candidates,replace} = Seed
+     284        1023 :         GRB_TRY (GrB_assign (Seed, candidates, NULL, Seed, GrB_ALL, n,
+     285             :             GrB_DESC_RS)) ;
+     286             : 
+     287             :         // Check for stall (can only occur if the matrix has self-edges, or in
+     288             :         // the exceedingly rare case that 2 nodes have the exact same score).
+     289             :         // If the method happens to stall, with no nodes selected because
+     290             :         // the scores happen to tie, try again with another random score.
+     291        1023 :         GRB_TRY (GrB_Vector_nvals (&ncandidates, candidates)) ;
+     292        1023 :         if (last_ncandidates == ncandidates)
+     293             :         {
+     294             :             // This case is nearly untestable since it can almost never occur.
+     295         429 :             nstall++ ;
+     296             :             // terminate if the method has stalled too many times
+     297         429 :             LG_ASSERT_MSG (nstall <= 32, -111, "stall") ;
+     298             :             // recreate the random number seeds with a new starting seed
+     299         416 :             LG_TRY (LAGraph_Random_Seed (Seed, seed + nstall, msg)) ;
+     300             :         }
+     301        1010 :         last_ncandidates = ncandidates ;
+     302             : 
+     303             :         // get the next random Seed vector
+     304        1010 :         LG_TRY (LAGraph_Random_Next (Seed, msg)) ;
+     305             :     }
+     306             : 
+     307             :     //--------------------------------------------------------------------------
+     308             :     // free workspace and return result
+     309             :     //--------------------------------------------------------------------------
+     310             : 
+     311         339 :     GRB_TRY (GrB_wait (iset, GrB_MATERIALIZE)) ;
+     312         339 :     (*mis) = iset ;
+     313         339 :     LG_FREE_WORK ;
+     314         339 :     return (GrB_SUCCESS) ;
+     315             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_SquareClustering.c.func-sort-c.html b/experimental/algorithm/LAGraph_SquareClustering.c.func-sort-c.html new file mode 100644 index 0000000000..dc6d24fd19 --- /dev/null +++ b/experimental/algorithm/LAGraph_SquareClustering.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_SquareClustering.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_SquareClustering.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3939100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_SquareClustering1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_SquareClustering.c.func.html b/experimental/algorithm/LAGraph_SquareClustering.c.func.html new file mode 100644 index 0000000000..50b1d71aa8 --- /dev/null +++ b/experimental/algorithm/LAGraph_SquareClustering.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_SquareClustering.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_SquareClustering.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3939100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_SquareClustering1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_SquareClustering.c.gcov.html b/experimental/algorithm/LAGraph_SquareClustering.c.gcov.html new file mode 100644 index 0000000000..16a9a7eaaf --- /dev/null +++ b/experimental/algorithm/LAGraph_SquareClustering.c.gcov.html @@ -0,0 +1,313 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_SquareClustering.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_SquareClustering.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3939100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_SquareClustering: vertex square-clustering
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Erik Welch, NVIDIA.
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // Compute the square clustering coefficient for each node of an undirected
+      19             : // graph, which is the fraction of possible squares that exist at each node.
+      20             : // It is a clustering coefficient suitable for bipartite graphs and is fully
+      21             : // described here:
+      22             : //      https://arxiv.org/pdf/0710.0117v1.pdf
+      23             : // which uses a different denominator than the original definition:
+      24             : //      https://arxiv.org/pdf/cond-mat/0504241.pdf
+      25             : // Furthermore, we count squares based on
+      26             : //      https://arxiv.org/pdf/2007.11111.pdf (sigma_12, c_4)
+      27             : // which is implemented in LAGraph_FastGraphletTransform.c (thanks Tim Davis
+      28             : // for mentioning this to me!).
+      29             : 
+      30             : // The NetworkX implementation of square clustering was used heavily during
+      31             : // development.  I used it to determine the contributions to the denominator
+      32             : // and to verify correctness (including on larger graphs).
+      33             : //      https://networkx.org/documentation/stable/reference/algorithms/\
+      34             : //      generated/networkx.algorithms.cluster.square_clustering.html
+      35             : 
+      36             : // Pseudocode (doesn't show dropping 0s in the final result):
+      37             : //
+      38             : //    P2(~degrees.diag().S) = plus_pair(A @ A.T)
+      39             : //    tri = first(P2 & A).reduce_rowwise()
+      40             : //    squares = (P2 * (P2 - 1)).reduce_rowwise() / 2
+      41             : //    uw_count = degrees * (degrees - 1)
+      42             : //    uw_degrees = plus_times(A @ degrees) * (degrees - 1)
+      43             : //    square_clustering = squares / (uw_degrees - uw_count - tri - squares)
+      44             : 
+      45             : // The coefficient as described in https://arxiv.org/pdf/0710.0117v1.pdf
+      46             : // where m and n are different neighbors of node i.
+      47             : // Note that summations over mn are implied in the numerator and denominator:
+      48             : //
+      49             : //    C_{4,mn}(i) = q_imn / ((k_m - eta_imn) + (k_n - eta_imn) + q_imn)
+      50             : //    q_imn = # of common neighbors between m and n (i.e., squares)
+      51             : //    k_m = number of neighbors of m (i.e., degrees[m])
+      52             : //    eta_imn = 1 + q_imn + theta_mn
+      53             : //    theta_mn = 1 if m and n are connected, otherwise 0 (i.e., triangles)
+      54             : 
+      55             : // Here are the corresponding terms between the equation and pseudocode:
+      56             : //    theta_mn          <--> tri
+      57             : //    q_imn             <--> squares
+      58             : //    eta_imn = 1 + ... <--> uw_count
+      59             : //    k_m               <--> uw_degrees
+      60             : 
+      61             : // I first implemented this in the Python library graphblas-algorithms
+      62             : //      https://github.com/python-graphblas/graphblas-algorithms/\
+      63             : //      blob/main/graphblas_algorithms/algorithms/cluster.py
+      64             : // and I copy/pasted C code generated from the Recorder in Python-graphblas
+      65             : //      https://github.com/python-graphblas/python-graphblas
+      66             : 
+      67             : // This implementation requires that `out_degree` property is already cached.
+      68             : // 0 values are omitted from the result (i.e., missing values <--> zero).
+      69             : // Also, it computes `P2 = A @ A.T`, which may be very large.  We could modify
+      70             : // the algorithm to compute coefficients for a subset of nodes, which would
+      71             : // allow expert users to compute in batches.  Also, since this algorithm only
+      72             : // operates on undirected or symmetric graphs, we only need to compute the
+      73             : // upper (or lower) triangle of P2, which should reduce memory by about half.
+      74             : // However, this is not easy to do, and would complicate the implementation.
+      75             : 
+      76             : //------------------------------------------------------------------------------
+      77             : 
+      78             : #define LG_FREE_WORK                \
+      79             : {                                   \
+      80             :     GrB_free (&squares) ;           \
+      81             :     GrB_free (&denom) ;             \
+      82             :     GrB_free (&neg_denom) ;         \
+      83             :     GrB_free (&P2) ;                \
+      84             :     GrB_free (&D) ;                 \
+      85             : }
+      86             : 
+      87             : #define LG_FREE_ALL                 \
+      88             : {                                   \
+      89             :     LG_FREE_WORK ;                  \
+      90             :     GrB_free (&r) ;                 \
+      91             : }
+      92             : 
+      93             : #include <LAGraph.h>
+      94             : #include <LAGraphX.h>
+      95             : #include <LG_internal.h>  // from src/utility
+      96             : 
+      97           1 : int LAGraph_SquareClustering
+      98             : (
+      99             :     // outputs:
+     100             :     GrB_Vector *square_clustering,
+     101             :     // inputs:
+     102             :     LAGraph_Graph G,
+     103             :     char *msg
+     104             : )
+     105             : {
+     106           1 :     LG_CLEAR_MSG ;
+     107             : 
+     108             :     // The number of squares each node is part of
+     109           1 :     GrB_Vector squares = NULL ;
+     110             : 
+     111             :     // Thought of as the total number of possible squares for each node
+     112           1 :     GrB_Vector denom = NULL ;
+     113             : 
+     114             :     // Negative contributions to the denominator
+     115           1 :     GrB_Vector neg_denom = NULL ;
+     116             : 
+     117             :     // Final result: the square coefficients for each node (squares / denom)
+     118           1 :     GrB_Vector r = NULL ;
+     119             : 
+     120             :     // out_degrees assigned to diagonal matrix
+     121             :     // Then used as triangles: first(P2 & A)
+     122           1 :     GrB_Matrix D = NULL ;
+     123             : 
+     124             :     // P2 = plus_pair(A @ A.T).new(mask=~D.S)
+     125             :     // Then used as a temporary workspace matrix (int64)
+     126           1 :     GrB_Matrix P2 = NULL ;
+     127             : 
+     128           1 :     GrB_Vector deg = G->out_degree ;
+     129           1 :     GrB_Matrix A = G->A ;
+     130           1 :     GrB_Index n = 0 ;
+     131             : 
+     132             :     //--------------------------------------------------------------------------
+     133             :     // check inputs
+     134             :     //--------------------------------------------------------------------------
+     135             : 
+     136           1 :     LG_ASSERT (square_clustering != NULL, GrB_NULL_POINTER) ;
+     137           1 :     (*square_clustering) = NULL ;
+     138             : 
+     139           1 :     LG_ASSERT_MSG (deg != NULL,
+     140             :         LAGRAPH_NOT_CACHED, "G->out_degree is required") ;
+     141             : 
+     142           1 :     LG_TRY (LAGraph_CheckGraph (G, msg)) ;
+     143             : 
+     144           1 :     LG_ASSERT_MSG ((G->kind == LAGraph_ADJACENCY_UNDIRECTED ||
+     145             :        (G->kind == LAGraph_ADJACENCY_DIRECTED &&
+     146             :         G->is_symmetric_structure == LAGraph_TRUE)),
+     147             :         LAGRAPH_SYMMETRIC_STRUCTURE_REQUIRED,
+     148             :         "G->A must be known to be symmetric") ;
+     149             : 
+     150             :     // # of nodes
+     151           1 :     GRB_TRY (GrB_Matrix_nrows (&n, A)) ;
+     152             : 
+     153             :     // out_degrees as a diagonal matrix.
+     154             :     #if LAGRAPH_SUITESPARSE
+     155             :         #if GxB_IMPLEMENTATION >= GxB_VERSION (7,0,0)
+     156             :         // SuiteSparse 7.x and later:
+     157           1 :         GRB_TRY (GrB_Matrix_diag(&D, deg, 0)) ;
+     158             :         #else
+     159             :         // SuiteSparse 6.x and earlier, which had the incorrect signature:
+     160             :         GRB_TRY (GrB_Matrix_new(&D, GrB_INT64, n, n)) ;
+     161             :         GRB_TRY (GrB_Matrix_diag(D, deg, 0)) ;
+     162             :         #endif
+     163             :     #else
+     164             :     // standard GrB:
+     165             :     GRB_TRY (GrB_Matrix_diag(&D, deg, 0)) ;
+     166             :     #endif
+     167             : 
+     168             :     // We use ~D.S as a mask so P2 won't have values along the diagonal.
+     169             :     //    P2(~D.S) = plus_pair(A @ A.T)
+     170           1 :     GRB_TRY (GrB_Matrix_new (&P2, GrB_INT64, n, n)) ;
+     171           1 :     GRB_TRY (GrB_mxm (P2, D, NULL, LAGraph_plus_one_int64, A, A, GrB_DESC_SCT1)) ;
+     172             : 
+     173             :     // Denominator is thought of as total number of squares that could exist.
+     174             :     // It has four terms (indicated below), and we use the definition from:
+     175             :     //      https://arxiv.org/pdf/0710.0117v1.pdf.
+     176             :     //
+     177             :     // (1) tri = first(P2 & A).reduce_rowwise()
+     178             :     // Subtract 1 for each edge where u-w or w-u are connected.
+     179             :     // In other words, triangles.  Use P2, since we already have it.
+     180             :     //     D = first(P2 & A)
+     181             :     //     neg_denom = D.reduce_rowwise()
+     182           1 :     GRB_TRY (GrB_Matrix_eWiseMult_BinaryOp (D, NULL, NULL, GrB_FIRST_INT64, P2,
+     183             :         A, NULL)) ;
+     184           1 :     GRB_TRY (GrB_Vector_new (&neg_denom, GrB_INT64, n)) ;
+     185           1 :     GRB_TRY (GrB_Matrix_reduce_Monoid (neg_denom, NULL, NULL,
+     186             :         GrB_PLUS_MONOID_INT64, D, NULL)) ;
+     187           1 :     GrB_free (&D) ;
+     188             : 
+     189             :     // squares = (P2 * (P2 - 1)).reduce_rowwise() / 2
+     190             :     // Now compute the number of squares (the numerator).  We count squares
+     191             :     // based on https://arxiv.org/pdf/2007.11111.pdf (sigma_12, c_4).
+     192             :     //     P2 *= P2 - 1
+     193             :     //     squares = P2.reduce_rowwise() / 2  (and drop zeros)
+     194           1 :     GRB_TRY (GrB_Matrix_apply_BinaryOp2nd_INT64 (P2, NULL, GrB_TIMES_INT64,
+     195             :         GrB_MINUS_INT64, P2, 1, NULL)) ;
+     196           1 :     GRB_TRY (GrB_Vector_new (&squares, GrB_INT64, n)) ;
+     197           1 :     GRB_TRY (GrB_Matrix_reduce_Monoid (squares, NULL, NULL,
+     198             :         GrB_PLUS_MONOID_INT64, P2, NULL)) ;
+     199           1 :     GrB_free (&P2) ;
+     200             :     // Divide by 2, and use squares as value mask to drop zeros
+     201           1 :     GRB_TRY (GrB_Vector_apply_BinaryOp2nd_INT64 (squares, squares, NULL,
+     202             :         GrB_DIV_INT64, squares, 2, GrB_DESC_R)) ;
+     203             : 
+     204             :     // (2) uw_count = degrees * (degrees - 1).
+     205             :     // Subtract 1 for each u and 1 for each w for all combos.
+     206             :     //    denom(squares.S) = degrees - 1
+     207           1 :     GRB_TRY (GrB_Vector_new (&denom, GrB_INT64, n)) ;
+     208           1 :     GRB_TRY (GrB_Vector_apply_BinaryOp2nd_INT64(denom, squares, NULL,
+     209             :         GrB_MINUS_INT64, deg, 1, GrB_DESC_S)) ;
+     210             :     // neg_denom += degrees * (degrees - 1)
+     211           1 :     GRB_TRY (GrB_Vector_eWiseMult_BinaryOp(neg_denom, NULL, GrB_PLUS_INT64,
+     212             :         GrB_TIMES_INT64, deg, denom, NULL)) ;
+     213             : 
+     214             :     // (3) uw_degrees = plus_times(A @ degrees) * (degrees - 1).
+     215             :     // The main contribution to (and only positive term of) the denominator:
+     216             :     // degrees[u] + degrees[w] for each u-w combo.
+     217             :     // Recall that `denom = degrees - 1` from above.
+     218             :     //    denom(denom.S) *= plus_times(A @ deg)
+     219           1 :     GRB_TRY (GrB_mxv(denom, denom, GrB_TIMES_INT64,
+     220             :         GrB_PLUS_TIMES_SEMIRING_INT64, A, deg, GrB_DESC_S)) ;
+     221             : 
+     222             :     // (4) squares.  Subtract the number of squares
+     223             :     //    denom -= neg_denom + squares
+     224           1 :     GRB_TRY (GrB_Vector_eWiseMult_BinaryOp(denom, NULL, GrB_MINUS_INT64,
+     225             :         GrB_PLUS_INT64, neg_denom, squares, NULL)) ;
+     226             : 
+     227             :     // square_clustering = squares / (uw_degrees - uw_count - tri - squares)
+     228             :     // Almost done!  Now compute the final result:
+     229             :     //    square_clustering = r = squares / denom
+     230           1 :     GRB_TRY (GrB_Vector_new (&r, GrB_FP64, n)) ;
+     231           1 :     GRB_TRY (GrB_Vector_eWiseMult_BinaryOp (r, NULL, NULL, GrB_DIV_FP64,
+     232             :         squares, denom, NULL)) ;
+     233             : 
+     234           1 :     (*square_clustering) = r ;
+     235           1 :     LG_FREE_WORK ;
+     236           1 :     return (GrB_SUCCESS) ;
+     237             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_VertexCentrality_Triangle.c.func-sort-c.html b/experimental/algorithm/LAGraph_VertexCentrality_Triangle.c.func-sort-c.html new file mode 100644 index 0000000000..401dc09fcc --- /dev/null +++ b/experimental/algorithm/LAGraph_VertexCentrality_Triangle.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_VertexCentrality_Triangle.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_VertexCentrality_Triangle.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:6868100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_VertexCentrality_Triangle49
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_VertexCentrality_Triangle.c.func.html b/experimental/algorithm/LAGraph_VertexCentrality_Triangle.c.func.html new file mode 100644 index 0000000000..8cf80d997d --- /dev/null +++ b/experimental/algorithm/LAGraph_VertexCentrality_Triangle.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_VertexCentrality_Triangle.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_VertexCentrality_Triangle.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:6868100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_VertexCentrality_Triangle49
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_VertexCentrality_Triangle.c.gcov.html b/experimental/algorithm/LAGraph_VertexCentrality_Triangle.c.gcov.html new file mode 100644 index 0000000000..d660945c75 --- /dev/null +++ b/experimental/algorithm/LAGraph_VertexCentrality_Triangle.c.gcov.html @@ -0,0 +1,394 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_VertexCentrality_Triangle.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_VertexCentrality_Triangle.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:6868100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_VertexCentrality_triangle: vertex triangle-centrality
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Tim Davis, Texas A&M University.
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // LAGraph_VertexCentrality_Triangle: computes the TriangleCentrality of
+      19             : // an undirected graph.  No self edges are allowed on the input graph.
+      20             : // Methods 2 and 3 can tolerate any edge weights (they are ignored; only the
+      21             : // structure of G->A is used).  Methods 1 and 1.5 require unit edge weights
+      22             : // (this could be modified); results are undefined if this condition doesn't
+      23             : // hold.
+      24             : 
+      25             : // P. Burkhardt, "Triangle centrality," https://arxiv.org/pdf/2105.00110.pdf,
+      26             : // April 2021.
+      27             : 
+      28             : // Method 3 is by far the fastest.
+      29             : 
+      30             : // This method uses pure GrB* methods from the v2.0 C API only.
+      31             : // It does not rely on any SuiteSparse:GraphBLAS extensions.
+      32             : 
+      33             : // TC0: in python (called TC1 in the first draft of the paper)
+      34             : //
+      35             : // def triangle_centrality1(A):
+      36             : //          T = A.mxm(A, mask=A)
+      37             : //          y = T.reduce_vector()
+      38             : //          k = y.reduce_float()
+      39             : //          return(1/k)*(3*(A @ y) - 2*(T @ y) + y)
+      40             : //          note: T@y is wrong. should be plus_second semiring
+      41             : 
+      42             : //  def TC1(A):
+      43             : //      # this was "Method 1.5" in a draft, note the T.one@y is now correct:
+      44             : //      T = A.mxm(A, mask=A, desc=ST1)
+      45             : //      y = T.reduce_vector()
+      46             : //      k = y.reduce_float()
+      47             : //      return (3 * (A @ y) - 2 * (T.one() @ y) + y) / k
+      48             : 
+      49             : //  def TC2(A):
+      50             : //      # this was TC2 in the first submission
+      51             : //      T = A.plus_pair(A, mask=A, desc=ST1)
+      52             : //      y = Vector.dense(FP64, A.nrows)
+      53             : //      T.reduce_vector(out=y, accum=FP64.plus)
+      54             : //      k = y.reduce_float()
+      55             : //      return (3 * A.plus_second(y) - 2 * T.plus_second(y) + y) / k
+      56             : 
+      57             : //  def TC3(A):
+      58             : //      M = A.tril(-1)
+      59             : //      T = A.plus_pair(A, mask=M, desc=ST1)
+      60             : //      y = T.reduce() + T.reduce(desc=ST0)
+      61             : //      k = y.reduce_float()
+      62             : //      return (
+      63             : //          3 * A.plus_second(y) -
+      64             : //          (2 * (T.plus_second(y) + T.plus_second(y, desc=ST0))) + y
+      65             : //      ) / k
+      66             : 
+      67             : //------------------------------------------------------------------------------
+      68             : 
+      69             : #define LG_FREE_WORK                \
+      70             : {                                   \
+      71             :     GrB_free (&T) ;                 \
+      72             :     GrB_free (&u) ;                 \
+      73             :     GrB_free (&w) ;                 \
+      74             :     GrB_free (&y) ;                 \
+      75             :     GrB_free (&L) ;                 \
+      76             : }
+      77             : 
+      78             : #define LG_FREE_ALL                 \
+      79             : {                                   \
+      80             :     LG_FREE_WORK ;                  \
+      81             :     GrB_free (centrality) ;         \
+      82             : }
+      83             : 
+      84             : #include "LG_internal.h"
+      85             : 
+      86             : //------------------------------------------------------------------------------
+      87             : // LAGraph_VertexCentrality_Triangle: vertex triangle-centrality
+      88             : //------------------------------------------------------------------------------
+      89             : 
+      90          49 : int LAGraph_VertexCentrality_Triangle       // vertex triangle-centrality
+      91             : (
+      92             :     // outputs:
+      93             :     GrB_Vector *centrality,     // centrality(i): triangle centrality of i
+      94             :     uint64_t *ntriangles,       // # of triangles in the graph
+      95             :     // inputs:
+      96             :     int method,                 // 0, 1, 2, or 3
+      97             :     LAGraph_Graph G,            // input graph
+      98             :     char *msg
+      99             : )
+     100             : {
+     101             : 
+     102             :     //--------------------------------------------------------------------------
+     103             :     // check inputs
+     104             :     //--------------------------------------------------------------------------
+     105             : 
+     106          49 :     LG_CLEAR_MSG ;
+     107          49 :     GrB_Matrix T = NULL, L = NULL, A = NULL ;
+     108          49 :     GrB_Vector y = NULL, u = NULL, w = NULL ;
+     109             : 
+     110          49 :     LG_ASSERT (centrality != NULL && ntriangles != NULL, GrB_NULL_POINTER) ;
+     111          48 :     (*centrality) = NULL ;
+     112          48 :     LG_TRY (LAGraph_CheckGraph (G, msg)) ;
+     113             : 
+     114          47 :     if (G->kind == LAGraph_ADJACENCY_UNDIRECTED ||
+     115          10 :        (G->kind == LAGraph_ADJACENCY_DIRECTED &&
+     116          10 :         G->is_symmetric_structure == LAGraph_TRUE))
+     117             :     {
+     118             :         // the structure of A is known to be symmetric
+     119          46 :         A = G->A ;
+     120             :     }
+     121             :     else
+     122             :     {
+     123             :         // A is not known to be symmetric
+     124           1 :         LG_ASSERT_MSG (false, -1005, "G->A must be symmetric") ;
+     125             :     }
+     126             : 
+     127             :     // no self edges can be present
+     128          46 :     LG_ASSERT_MSG (G->nself_edges == 0, -1004, "G->nself_edges must be zero") ;
+     129             : 
+     130             :     //--------------------------------------------------------------------------
+     131             :     // create the T matrix
+     132             :     //--------------------------------------------------------------------------
+     133             : 
+     134             :     GrB_Index n ;
+     135          45 :     GRB_TRY (GrB_Matrix_nrows (&n, A)) ;
+     136          45 :     GRB_TRY (GrB_Matrix_new (&T, GrB_FP64, n, n)) ;
+     137          45 :     double k = 0 ;
+     138             : 
+     139             :     //--------------------------------------------------------------------------
+     140             :     // compute the Triangle Centrality
+     141             :     //--------------------------------------------------------------------------
+     142             : 
+     143          45 :     if (method == 0 || method == 1)
+     144          27 :     {
+     145             : 
+     146             :         //----------------------------------------------------------------------
+     147             :         // TC0, TC1: simplest method, requires that A has all entries equal to 1
+     148             :         //----------------------------------------------------------------------
+     149             : 
+     150             :         // todo: remove this method when moving this code from experimental/
+     151             :         // to src/
+     152             : 
+     153          27 :         if (method == 0)
+     154             :         {
+     155             :             // T<A> = A*A : method 0 (was TC1 in the first paper submission)
+     156          18 :             GRB_TRY (GrB_mxm (T, A, NULL, GrB_PLUS_TIMES_SEMIRING_FP64, A, A,
+     157             :                 NULL)) ;
+     158             :         }
+     159             :         else
+     160             :         {
+     161             :             // this is faster than method 0
+     162             :             // T<A> = A*A' : method TC1 (was method TC1.5)
+     163           9 :             GRB_TRY (GrB_mxm (T, A, NULL, GrB_PLUS_TIMES_SEMIRING_FP64, A, A,
+     164             :                 GrB_DESC_T1)) ;
+     165             :         }
+     166             : 
+     167             :         // y = sum (T), where y(i) = sum (T (i,:)) and y(i)=0 of T(i,:) is empty
+     168          27 :         GRB_TRY (GrB_Vector_new (&y, GrB_FP64, n)) ;
+     169          27 :         GRB_TRY (GrB_reduce (y, NULL, NULL, GrB_PLUS_MONOID_FP64, T, NULL)) ;
+     170             : 
+     171             :         // k = sum (y)
+     172          27 :         GRB_TRY (GrB_reduce (&k, NULL, GrB_PLUS_MONOID_FP64, y, NULL)) ;
+     173             : 
+     174             :         // T = spones (T)
+     175          27 :         GRB_TRY (GrB_assign (T, T, NULL, (double) 1, GrB_ALL, n, GrB_ALL, n,
+     176             :             GrB_DESC_S)) ;
+     177             : 
+     178             :         // centrality = (3*A*y - 2*T*y + y) / k
+     179             : 
+     180             :         // w = T*y
+     181          27 :         GRB_TRY (GrB_Vector_new (&w, GrB_FP64, n)) ;
+     182          27 :         GRB_TRY (GrB_mxv (w, NULL, NULL, GrB_PLUS_TIMES_SEMIRING_FP64, T, y,
+     183             :             NULL)) ;
+     184             : 
+     185             :         // w = (-2)*w
+     186          27 :         double minus_two = -2 ;
+     187          27 :         GRB_TRY (GrB_apply (w, NULL, NULL, GrB_TIMES_FP64, minus_two, w,
+     188             :             NULL)) ;
+     189             : 
+     190             :         // u = A*y
+     191          27 :         GRB_TRY (GrB_Vector_new (&u, GrB_FP64, n)) ;
+     192          27 :         GRB_TRY (GrB_mxv (u, NULL, NULL, GrB_PLUS_TIMES_SEMIRING_FP64, A, y,
+     193             :             NULL)) ;
+     194             : 
+     195             :     }
+     196          18 :     else if (method == 2)
+     197             :     {
+     198             : 
+     199             :         //----------------------------------------------------------------------
+     200             :         // TC2: using LAGraph_plus_one_fp64 semiring
+     201             :         //----------------------------------------------------------------------
+     202             : 
+     203             :         // todo: remove this method when moving this code from experimental/
+     204             :         // to src/
+     205             : 
+     206             :         // T{A} = A*A' (each triangle is seen 6 times)
+     207           9 :         GRB_TRY (GrB_mxm (T, A, NULL, LAGraph_plus_one_fp64, A, A,
+     208             :             GrB_DESC_ST1)) ;
+     209             : 
+     210             :         // y = sum (T), where y(i) = sum (T (i,:)) and y(i)=0 of T(i,:) is empty
+     211           9 :         GRB_TRY (GrB_Vector_new (&y, GrB_FP64, n)) ;
+     212           9 :         GRB_TRY (GrB_assign (y, NULL, NULL, ((double) 0), GrB_ALL, n, NULL)) ;
+     213           9 :         GRB_TRY (GrB_reduce (y, NULL, GrB_PLUS_FP64, GrB_PLUS_MONOID_FP64, T,
+     214             :             NULL)) ;
+     215             : 
+     216             :         // k = sum (y)
+     217           9 :         GRB_TRY (GrB_reduce (&k, NULL, GrB_PLUS_MONOID_FP64, y, NULL)) ;
+     218             : 
+     219             :         // centrality = (3*A*y - 2*T*y + y) / k
+     220             : 
+     221             :         // w = T*y
+     222           9 :         GRB_TRY (GrB_Vector_new (&w, GrB_FP64, n)) ;
+     223           9 :         GRB_TRY (GrB_mxv (w, NULL, NULL, LAGraph_plus_second_fp64, T, y,
+     224             :             NULL)) ;
+     225             : 
+     226             :         // w = (-2)*w
+     227           9 :         double minus_two = -2 ;
+     228           9 :         GRB_TRY (GrB_apply (w, NULL, NULL, GrB_TIMES_FP64, minus_two, w,
+     229             :             NULL)) ;
+     230             : 
+     231             :         // u = A*y
+     232           9 :         GRB_TRY (GrB_Vector_new (&u, GrB_FP64, n)) ;
+     233           9 :         GRB_TRY (GrB_mxv (u, NULL, NULL, LAGraph_plus_second_fp64, A, y,
+     234             :             NULL)) ;
+     235             : 
+     236             :     }
+     237           9 :     else if (method == 3)
+     238             :     {
+     239             : 
+     240             :         //----------------------------------------------------------------------
+     241             :         // TC3: using tril.  This is the fastest method.
+     242             :         //----------------------------------------------------------------------
+     243             : 
+     244             :         // todo: When this method is moved to src/, keep this method only.
+     245             : 
+     246             :         // L = tril (A,-1)
+     247           9 :         GRB_TRY (GrB_Matrix_new (&L, GrB_FP64, n, n)) ;
+     248           9 :         GRB_TRY (GrB_select (L, NULL, NULL, GrB_TRIL, A, (int64_t) (-1),
+     249             :             NULL)) ;
+     250             : 
+     251             :         // T{L}= A*A' (each triangle is seen 3 times; T is lower triangular)
+     252           9 :         GRB_TRY (GrB_mxm (T, L, NULL, LAGraph_plus_one_fp64, A, A,
+     253             :             GrB_DESC_ST1)) ;
+     254           9 :         GRB_TRY (GrB_free (&L)) ;
+     255             : 
+     256             :         // y = sum (T'), where y(j) = sum (T (:,j)) and y(j)=0 if T(:,j) empty
+     257           9 :         GRB_TRY (GrB_Vector_new (&y, GrB_FP64, n)) ;
+     258           9 :         GRB_TRY (GrB_assign (y, NULL, NULL, ((double) 0), GrB_ALL, n, NULL)) ;
+     259           9 :         GRB_TRY (GrB_reduce (y, NULL, GrB_PLUS_FP64, GrB_PLUS_MONOID_FP64, T,
+     260             :             GrB_DESC_T0)) ;
+     261             :         // y += sum (T)
+     262           9 :         GRB_TRY (GrB_reduce (y, NULL, GrB_PLUS_FP64, GrB_PLUS_MONOID_FP64, T,
+     263             :             NULL)) ;
+     264             : 
+     265             :         // k = sum (y).  y is the same as the other methods, above, just
+     266             :         // computed using the lower triangular matrix T.  So k/6 is the total
+     267             :         // number of triangles in the graph.
+     268           9 :         GRB_TRY (GrB_reduce (&k, NULL, GrB_PLUS_MONOID_FP64, y, NULL)) ;
+     269             : 
+     270             :         // centrality = (3*A*y - 2* (T*y + T'*y) + y) / k
+     271             : 
+     272             :         // w = T*y
+     273           9 :         GRB_TRY (GrB_Vector_new (&w, GrB_FP64, n)) ;
+     274           9 :         GRB_TRY (GrB_mxv (w, NULL, NULL, LAGraph_plus_second_fp64, T, y,
+     275             :             NULL)) ;
+     276             :         // w += T'*y
+     277           9 :         GRB_TRY (GrB_mxv (w, NULL, GrB_PLUS_FP64, LAGraph_plus_second_fp64,
+     278             :             T, y, GrB_DESC_T0)) ;
+     279             : 
+     280             :         // w = (-2)*w
+     281           9 :         double minus_two = -2 ;
+     282           9 :         GRB_TRY (GrB_apply (w, NULL, NULL, GrB_TIMES_FP64, minus_two, w,
+     283             :             NULL)) ;
+     284             : 
+     285             :         // u = A*y
+     286           9 :         GRB_TRY (GrB_Vector_new (&u, GrB_FP64, n)) ;
+     287           9 :         GRB_TRY (GrB_mxv (u, NULL, NULL, LAGraph_plus_second_fp64, A, y,
+     288             :             NULL)) ;
+     289             : 
+     290             :     }
+     291             : 
+     292             :     //--------------------------------------------------------------------------
+     293             :     // centrality = (3*u + w + y) / k for all 4 methods
+     294             :     //--------------------------------------------------------------------------
+     295             : 
+     296             :     // centrality = 3*u
+     297          45 :     GRB_TRY (GrB_Vector_new (centrality, GrB_FP64, n)) ;
+     298          45 :     const double three = 3 ;
+     299          45 :     GRB_TRY (GrB_apply (*centrality, NULL, NULL, GrB_TIMES_FP64, three, u,
+     300             :         NULL)) ;
+     301             : 
+     302             :     // centrality += (w + y)
+     303          45 :     GRB_TRY (GrB_eWiseAdd (*centrality, NULL, GrB_PLUS_FP64, GrB_PLUS_FP64,
+     304             :         w, y, NULL)) ;
+     305             : 
+     306             :     // centrality = centrality / k
+     307          45 :     GRB_TRY (GrB_apply (*centrality, NULL, NULL, GrB_TIMES_FP64,
+     308             :         ((k == 0) ? 1.0 : (1.0/k)), *centrality, NULL)) ;
+     309             : 
+     310          45 :     (*ntriangles) = (uint64_t) (k/6) ;     // # triangles is k/6 for all methods
+     311             : 
+     312             :     //--------------------------------------------------------------------------
+     313             :     // free workspace and return result
+     314             :     //--------------------------------------------------------------------------
+     315             : 
+     316          45 :     LG_FREE_WORK ;
+     317          45 :     return (GrB_SUCCESS) ;
+     318             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_cc_lacc.c.func-sort-c.html b/experimental/algorithm/LAGraph_cc_lacc.c.func-sort-c.html new file mode 100644 index 0000000000..a7299f0629 --- /dev/null +++ b/experimental/algorithm/LAGraph_cc_lacc.c.func-sort-c.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_cc_lacc.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_cc_lacc.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:110110100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_cc_lacc36
Reduce_assign188
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_cc_lacc.c.func.html b/experimental/algorithm/LAGraph_cc_lacc.c.func.html new file mode 100644 index 0000000000..f4d3cfb57a --- /dev/null +++ b/experimental/algorithm/LAGraph_cc_lacc.c.func.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_cc_lacc.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_cc_lacc.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:110110100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_cc_lacc36
Reduce_assign188
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_cc_lacc.c.gcov.html b/experimental/algorithm/LAGraph_cc_lacc.c.gcov.html new file mode 100644 index 0000000000..4760ef1b2f --- /dev/null +++ b/experimental/algorithm/LAGraph_cc_lacc.c.gcov.html @@ -0,0 +1,306 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_cc_lacc.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_cc_lacc.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:110110100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_cc_lacc.c
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Scott McMillan, SEI, Carnegie Mellon University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : /**
+      19             :  * Code is based on the algorithm described in the following paper Azad, Buluc;
+      20             :  * LACC: a linear-algebraic algorithm for finding connected components in
+      21             :  * distributed memory (IPDPS 2019)
+      22             :  **/
+      23             : 
+      24             : #define LG_FREE_ALL         \
+      25             : {                           \
+      26             :     free(I);                \
+      27             :     free(V);                \
+      28             :     GrB_free (&S2) ;        \
+      29             :     GrB_free (&stars);      \
+      30             :     GrB_free (&mask);       \
+      31             :     GrB_free (&parents);    \
+      32             :     GrB_free (&gp);         \
+      33             :     GrB_free (&mnp);        \
+      34             :     GrB_free (&hookMNP);    \
+      35             :     GrB_free (&hookP);      \
+      36             :     GrB_free (&pNonstars);  \
+      37             :     GrB_free (&tmp);        \
+      38             :     GrB_free (&nsgp);       \
+      39             : }
+      40             : 
+      41             : #include "LG_internal.h"
+      42             : #include <LAGraph.h>
+      43             : #include <LAGraphX.h>
+      44             : 
+      45             : //****************************************************************************
+      46             : // mask = NULL, accumulator = GrB_MIN_UINT64, descriptor = NULL
+      47         188 : static GrB_Info Reduce_assign (GrB_Vector w,
+      48             :                                GrB_Vector src,
+      49             :                                GrB_Index *index,
+      50             :                                GrB_Index nLocs)
+      51             : {
+      52             :     GrB_Index nw, ns;
+      53         188 :     GrB_Vector_nvals(&nw, w);
+      54         188 :     GrB_Vector_nvals(&ns, src);
+      55         188 :     GrB_Index *mem = (GrB_Index*) malloc(sizeof(GrB_Index) * nw * 3);
+      56         188 :     GrB_Index *ind = mem, *sval = mem + nw, *wval = sval + nw;
+      57         188 :     GrB_Vector_extractTuples(ind, wval, &nw, w);
+      58         188 :     GrB_Vector_extractTuples(ind, sval, &ns, src);
+      59       10346 :     for (GrB_Index i = 0; i < nLocs; i++)
+      60       10158 :         if (sval[i] < wval[index[i]])
+      61        9486 :             wval[index[i]] = sval[i];
+      62         188 :     GrB_Vector_clear(w);
+      63         188 :     GrB_Vector_build(w, ind, wval, nw, GrB_PLUS_UINT64);
+      64         188 :     free(mem);
+      65         188 :     return GrB_SUCCESS;
+      66             : }
+      67             : 
+      68             : //****************************************************************************
+      69          36 : int LAGraph_cc_lacc
+      70             : (
+      71             :     GrB_Vector *result,     // output: array of component identifiers
+      72             :     GrB_Matrix A,           // input matrix
+      73             :     bool sanitize,          // if true, ensure A is symmetric
+      74             :     char *msg
+      75             : )
+      76             : {
+      77             :     //--------------------------------------------------------------------------
+      78             :     // check inputs
+      79             :     //--------------------------------------------------------------------------
+      80             : 
+      81          36 :     LG_CLEAR_MSG ;
+      82          36 :     if (result == NULL)
+      83             :     {
+      84          12 :         return (GrB_NULL_POINTER) ;
+      85             :     }
+      86             : 
+      87             :     GrB_Info info;
+      88             : 
+      89          24 :     GrB_Vector stars = NULL, mask = NULL;
+      90          24 :     GrB_Vector parents = NULL, gp = NULL, mnp = NULL;
+      91          24 :     GrB_Vector hookMNP = NULL, hookP = NULL;
+      92          24 :     GrB_Vector tmp = NULL, pNonstars = NULL, nsgp = NULL; // temporary
+      93          24 :     GrB_Index *I = NULL;
+      94          24 :     GrB_Index *V = NULL;
+      95          24 :     GrB_Matrix S = NULL, S2 = NULL ;
+      96             : 
+      97             :     GrB_Index n ;
+      98          24 :     GRB_TRY (GrB_Matrix_nrows (&n, A)) ;
+      99             :     //GrB_Index nnz ;
+     100             :     //GRB_TRY (GrB_Matrix_nvals (&nnz, A)) ;
+     101             :     //printf ("number of nodes: %g\n", (double) n) ;
+     102             :     //printf ("number of edges: %g\n", (double) nnz) ;
+     103             : 
+     104          24 :     if (sanitize)
+     105             :     {
+     106          12 :         GRB_TRY (GrB_Matrix_new (&S2, GrB_BOOL, n, n)) ;
+     107          12 :         GRB_TRY (GrB_eWiseAdd (S2, NULL, NULL, GrB_LOR, A, A, GrB_DESC_T1)) ;
+     108          12 :         S = S2 ;
+     109             :     }
+     110             :     else
+     111             :     {
+     112             :         // Use the input as-is, and assume it is binary and symmetric
+     113          12 :         S = A ;
+     114             :     }
+     115             : 
+     116             :     // vectors
+     117          24 :     GRB_TRY (GrB_Vector_new (&stars, GrB_BOOL, n));
+     118          24 :     GRB_TRY (GrB_Vector_new (&mask, GrB_BOOL, n));
+     119          24 :     GRB_TRY (GrB_Vector_new (&parents, GrB_UINT64, n));
+     120          24 :     GRB_TRY (GrB_Vector_new (&gp, GrB_UINT64, n));
+     121          24 :     GRB_TRY (GrB_Vector_new (&hookMNP, GrB_UINT64, n));
+     122          24 :     GRB_TRY (GrB_Vector_new (&hookP, GrB_UINT64, n));
+     123          24 :     GRB_TRY (GrB_Vector_new (&pNonstars, GrB_UINT64, n));
+     124             : 
+     125             :     // temporary arrays
+     126          24 :     I = malloc(sizeof(GrB_Index) * n);
+     127          24 :     V = malloc(sizeof(GrB_Index) * n);
+     128             : 
+     129             :     // prepare the vectors
+     130       16284 :     for (GrB_Index i = 0 ; i < n ; i++)
+     131       16260 :         I[i] = V[i] = i;
+     132          24 :     GRB_TRY (GrB_Vector_build (parents, I, V, n, GrB_PLUS_UINT64));
+     133          24 :     GRB_TRY (GrB_Vector_dup (&mnp, parents));
+     134          24 :     GRB_TRY (GrB_assign (stars, 0, 0, true, GrB_ALL, 0, 0)) ;
+     135             : 
+     136             :     // main computation
+     137             :     GrB_Index nHooks, nStars, nNonstars;
+     138             :     while (true) {
+     139             :         // ---------------------------------------------------------
+     140             :         // CondHook(A, parents, stars);
+     141             :         // ---------------------------------------------------------
+     142          94 :         GRB_TRY (GrB_mxv (mnp, 0, 0, GrB_MIN_SECOND_SEMIRING_UINT64,
+     143             :                              S, parents, 0));
+     144          94 :         GRB_TRY (GrB_Vector_clear (mask));
+     145          94 :         GRB_TRY (GrB_eWiseMult(mask, stars, 0, GrB_LT_UINT64, mnp, parents, 0));
+     146          94 :         GRB_TRY (GrB_assign (hookMNP, mask, 0, mnp, GrB_ALL, n, 0));
+     147          94 :         GRB_TRY (GrB_eWiseMult (hookP, 0, 0, GrB_SECOND_UINT64, hookMNP, parents, 0));
+     148          94 :         GRB_TRY (GrB_Vector_clear (mnp));
+     149          94 :         GRB_TRY (GrB_Vector_nvals (&nHooks, hookP));
+     150          94 :         GRB_TRY (GrB_Vector_extractTuples (I, V, &nHooks, hookP));
+     151          94 :         GRB_TRY (GrB_Vector_new (&tmp, GrB_UINT64, nHooks));
+     152          94 :         GRB_TRY (GrB_extract (tmp, 0, 0, hookMNP, I, nHooks, 0));
+     153          94 :         LG_TRY (Reduce_assign (parents, tmp, V, nHooks));
+     154          94 :         GRB_TRY (GrB_Vector_clear (tmp));
+     155             :         // modify the stars vector
+     156          94 :         GRB_TRY (GrB_assign (stars, 0, 0, false, V, nHooks, 0));
+     157          94 :         GRB_TRY (GrB_extract (tmp, 0, 0, parents, V, nHooks, 0)); // extract modified parents
+     158          94 :         GRB_TRY (GrB_Vector_extractTuples (I, V, &nHooks, tmp));
+     159          94 :         GRB_TRY (GrB_assign (stars, 0, 0, false, V, nHooks, 0));
+     160          94 :         GRB_TRY (GrB_Vector_extractTuples (I, V, &n, parents));
+     161          94 :         GRB_TRY (GrB_extract (mask, 0, 0, stars, V, n, 0));
+     162          94 :         GRB_TRY (GrB_assign (stars, 0, GrB_LAND, mask, GrB_ALL, 0, 0));
+     163             :         // clean up
+     164          94 :         GRB_TRY (GrB_Vector_clear (hookMNP));
+     165          94 :         GRB_TRY (GrB_Vector_clear (hookP));
+     166          94 :         GRB_TRY (GrB_free (&tmp));
+     167             :         // ---------------------------------------------------------
+     168             :         // UnCondHook(A, parents, stars);
+     169             :         // ---------------------------------------------------------
+     170          94 :         GRB_TRY (GrB_assign (pNonstars, 0, 0, parents, GrB_ALL, 0, 0));
+     171          94 :         GRB_TRY (GrB_assign (pNonstars, stars, 0, n, GrB_ALL, 0, 0));
+     172          94 :         GRB_TRY (GrB_mxv (hookMNP, stars, 0, GrB_MIN_SECOND_SEMIRING_UINT64,
+     173             :                              S, pNonstars, 0));
+     174             :         // select the valid elemenets (<n) of hookMNP
+     175          94 :         GRB_TRY (GrB_assign (pNonstars, 0, 0, n, GrB_ALL, 0, 0));
+     176          94 :         GRB_TRY (GrB_eWiseMult (mask, 0, 0, GrB_LT_UINT64, hookMNP, pNonstars, 0));
+     177          94 :         GRB_TRY (GrB_eWiseMult (hookP, mask, 0, GrB_SECOND_UINT64, hookMNP, parents, 0));
+     178          94 :         GRB_TRY (GrB_Vector_nvals (&nHooks, hookP));
+     179          94 :         GRB_TRY (GrB_Vector_extractTuples (I, V, &nHooks, hookP));
+     180          94 :         GRB_TRY (GrB_Vector_new (&tmp, GrB_UINT64, nHooks));
+     181          94 :         GRB_TRY (GrB_extract (tmp, 0, 0, hookMNP, I, nHooks, 0));
+     182          94 :         GRB_TRY (GrB_assign (parents, 0, 0, n, V, nHooks, 0)); // !!
+     183          94 :         LG_TRY (Reduce_assign (parents, tmp, V, nHooks));
+     184             :         // modify the star vector
+     185          94 :         GRB_TRY (GrB_assign (stars, 0, 0, false, V, nHooks, 0));
+     186          94 :         GRB_TRY (GrB_Vector_extractTuples (I, V, &n, parents));
+     187          94 :         GRB_TRY (GrB_extract (mask, 0, 0, stars, V, n, 0));
+     188          94 :         GRB_TRY (GrB_assign (stars, 0, GrB_LAND, mask, GrB_ALL, 0, 0));
+     189             :         // check termination
+     190          94 :         GRB_TRY (GrB_reduce (&nStars, 0, GrB_PLUS_MONOID_UINT64, stars, 0));
+     191          94 :         if (nStars == n) break;
+     192             :         // clean up
+     193          70 :         GRB_TRY (GrB_Vector_clear(hookMNP));
+     194          70 :         GRB_TRY (GrB_Vector_clear(hookP));
+     195          70 :         GRB_TRY (GrB_Vector_clear(pNonstars));
+     196          70 :         GRB_TRY (GrB_free (&tmp));
+     197             :         // ---------------------------------------------------------
+     198             :         // Shortcut(parents);
+     199             :         // ---------------------------------------------------------
+     200          70 :         GRB_TRY (GrB_Vector_extractTuples (I, V, &n, parents));
+     201          70 :         GRB_TRY (GrB_extract (gp, 0, 0, parents, V, n, 0));
+     202          70 :         GRB_TRY (GrB_assign (parents, 0, 0, gp, GrB_ALL, 0, 0));
+     203             :         // ---------------------------------------------------------
+     204             :         // StarCheck(parents, stars);
+     205             :         // ---------------------------------------------------------
+     206             :         // calculate grandparents
+     207          70 :         GRB_TRY (GrB_Vector_extractTuples (I, V, &n, parents));
+     208          70 :         GRB_TRY (GrB_extract (gp, 0, 0, parents, V, n, 0));
+     209             :         // identify vertices whose parent and grandparent are different
+     210          70 :         GRB_TRY (GrB_eWiseMult (mask, 0, 0, GrB_NE_UINT64, gp, parents, 0));
+     211          70 :         GRB_TRY (GrB_Vector_new (&nsgp, GrB_UINT64, n));
+     212          70 :         GRB_TRY (GrB_assign (nsgp, mask, 0, gp, GrB_ALL, 0, 0));
+     213             :         // extract indices and values for assign
+     214          70 :         GRB_TRY (GrB_Vector_nvals (&nNonstars, nsgp));
+     215          70 :         GRB_TRY (GrB_Vector_extractTuples (I, V, &nNonstars, nsgp));
+     216          70 :         GRB_TRY (GrB_free (&nsgp));
+     217          70 :         GRB_TRY (GrB_assign (stars, 0, 0, true, GrB_ALL, 0, 0));
+     218          70 :         GRB_TRY (GrB_assign (stars, 0, 0, false, I, nNonstars, 0));
+     219          70 :         GRB_TRY (GrB_assign (stars, 0, 0, false, V, nNonstars, 0));
+     220             :         // extract indices and values for assign
+     221          70 :         GRB_TRY (GrB_Vector_extractTuples (I, V, &n, parents));
+     222          70 :         GRB_TRY (GrB_extract (mask, 0, 0, stars, V, n, 0));
+     223          70 :         GRB_TRY (GrB_assign (stars, 0, GrB_LAND, mask, GrB_ALL, 0, 0));
+     224             :     }
+     225          24 :     *result = parents;
+     226          24 :     parents = NULL ;        // return parents (set to NULL so it isn't freed)
+     227             : 
+     228          24 :     LG_FREE_ALL;
+     229          24 :     return GrB_SUCCESS;
+     230             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_cdlp.c.func-sort-c.html b/experimental/algorithm/LAGraph_cdlp.c.func-sort-c.html new file mode 100644 index 0000000000..9236f00b94 --- /dev/null +++ b/experimental/algorithm/LAGraph_cdlp.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_cdlp.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_cdlp.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:9393100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_cdlp12
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_cdlp.c.func.html b/experimental/algorithm/LAGraph_cdlp.c.func.html new file mode 100644 index 0000000000..f230f26e8b --- /dev/null +++ b/experimental/algorithm/LAGraph_cdlp.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_cdlp.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_cdlp.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:9393100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_cdlp12
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_cdlp.c.gcov.html b/experimental/algorithm/LAGraph_cdlp.c.gcov.html new file mode 100644 index 0000000000..91e59730f6 --- /dev/null +++ b/experimental/algorithm/LAGraph_cdlp.c.gcov.html @@ -0,0 +1,435 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_cdlp.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_cdlp.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:9393100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_cdlp: community detection using label propagation
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Gabor Szarnyas and Balint Hegyi, Budapest University of
+      15             : // Technology and Economics (with accented characters: G\'{a}bor Sz\'{a}rnyas
+      16             : // and B\'{a}lint Hegyi, using LaTeX syntax).
+      17             : // https://inf.mit.bme.hu/en/members/szarnyasg .
+      18             : 
+      19             : //------------------------------------------------------------------------------
+      20             : 
+      21             : // ## Background
+      22             : //
+      23             : // This function was originally written for the LDBC Graphalytics benchmark.
+      24             : //
+      25             : // The community detection using label propagation (CDLP) algorithm is
+      26             : // defined both for directed and undirected graphs.
+      27             : //
+      28             : // The definition implemented here is described in the following document:
+      29             : // https://ldbc.github.io/ldbc_graphalytics_docs/graphalytics_spec.pdf
+      30             : //
+      31             : // The algorithm is based on the one given in the following paper:
+      32             : //
+      33             : // Usha Raghavan, Reka Albert, and Soundar Kumara. "Near linear time algorithm
+      34             : // to detect community structures in large-scale networks". In: Physical
+      35             : // Review E 76.3 (2007), p. 036106, https://arxiv.org/abs/0709.2938
+      36             : //
+      37             : // The key idea of the algorithm is that each vertex is assigned the label
+      38             : // that is most frequent among its neighbors. To allow reproducible
+      39             : // experiments, the algorithm is modified to guarantee deterministic behavior:
+      40             : // it always picks the smallest label in case of a tie:
+      41             : //
+      42             : // min ( argmax_{l} (#neighbors with label l) )
+      43             : //
+      44             : // In other words, we need to compute the *minimum mode value* (minmode) for
+      45             : // the labels among the neighbors.
+      46             : //
+      47             : // For directed graphs, a label on a neighbor that is connected through both
+      48             : // an outgoing and on an incoming edge counts twice:
+      49             : //
+      50             : // min ( argmax_{l} (#incoming neighbors with l + #outgoing neighbors with l) )
+      51             : //
+      52             : // ## Example (undirected)
+      53             : //
+      54             : // For an example, let's assume an undirected graph where vertex 1 has four
+      55             : // neighbors {2, 3, 4, 5}, and the current labels in the graph are
+      56             : // L = [3, 5, 4, 5, 4].
+      57             : //
+      58             : // In this example, the distribution of labels among the neighbors of vertex 1
+      59             : // is {4 => 2, 5 => 2}, therefore, the minimum mode value is 4.
+      60             : //
+      61             : // Next, we capture this operation using GraphBLAS operations and
+      62             : // data structures. Notice that the neighbors of vertex 1 are encoded
+      63             : // as a sparse vector in the adjacency matrix:
+      64             : //
+      65             : // A = | 0 1 1 1 1 |
+      66             : //     | 1 . . .   |
+      67             : //     | 1 .       |
+      68             : //     | 1 .       |
+      69             : //     | 1         |
+      70             : //
+      71             : // To allow propagating the labels along edges, we use a diagonal matrix
+      72             : // with the elements of the diagonal set to the values of L:
+      73             : //
+      74             : // diag(L) = | 3 0 0 0 0 |
+      75             : //           | 0 5 0 0 0 |
+      76             : //           | 0 0 4 0 0 |
+      77             : //           | 0 0 0 5 0 |
+      78             : //           | 0 0 0 0 4 |
+      79             : //
+      80             : // If we multiply adjacency matrix with diag(L), we get a matrix
+      81             : // containing the labels of the neighbor nodes. We use the 'sel2nd' operator
+      82             : // for multiplication to avoid having to lookup the value on the left.
+      83             : // The conventional plus.times semiring would also work: 1 * y = sel2nd(1, y).
+      84             : // Note that we multiply with a diagonal matrix so the addition operator
+      85             : // is not used. In the implementation, we use "min" so the semiring is
+      86             : // "min.sel2nd" on uint64 values.
+      87             : //
+      88             : // In the example, this gives the following:
+      89             : //
+      90             : // AL = A min.sel2nd diag(L) = | 0 5 4 5 4 |
+      91             : //                             | 3 . . . . |
+      92             : //
+      93             : // ## Selecting the minimum mode value
+      94             : //
+      95             : // Next, we need to compute the minimum mode value for each row. As it is
+      96             : // difficult to capture this operation as a monoid, we use a sort operation
+      97             : // on each row. In the undirected case, we extract tuples <I, _, X> from the
+      98             : // matrix, then use <I, X> for sorting. In the directed case, we extract
+      99             : // tuples <I1, _, X1> and <I2, _, X2>, then use <I1+I2, X1+X2>,
+     100             : // where '+' denotes concatenation. Column indices (J) are not used.
+     101             : //
+     102             : // The resulting two-tuples are sorted using a parallel merge sort.
+     103             : // Finally, we use the sorted arrays compute the minimum mode value for each
+     104             : // row.
+     105             : //
+     106             : // ## Fixed point
+     107             : //
+     108             : // At the end of each iteration, we check whether L[i-1] == L[i] and
+     109             : // terminate if we reached a fixed point.
+     110             : //
+     111             : // ## Further optimizations
+     112             : //
+     113             : // A possible optimization is that the first iteration is rather trivial:
+     114             : //
+     115             : // * in the undirected case, each vertex gets the minimal initial label (=id)
+     116             : //   of its neighbors.
+     117             : // * in the directed case, each vertex gets the minimal initial label (=id)
+     118             : //   of its neighbors which are doubly-linked (on an incoming and on an
+     119             : //   outgoing edge). In the absence of such a neighbor, it picks the minimal
+     120             : //   label of its neighbors (connected through either an incoming or through
+     121             : //   an outgoing edge).
+     122             : 
+     123             : #define LG_FREE_ALL                                                     \
+     124             : {                                                                       \
+     125             :     LAGraph_Free ((void *) &I, NULL) ;                                  \
+     126             :     LAGraph_Free ((void *) &X, NULL) ;                                  \
+     127             :     LAGraph_Free ((void *) &AI, NULL) ;                                 \
+     128             :     LAGraph_Free ((void *) &AJ, NULL) ;                                 \
+     129             :     LAGraph_Free ((void *) &AX, NULL) ;                                 \
+     130             :     LAGraph_Free ((void *) &X, NULL) ;                                  \
+     131             :     LAGraph_Free ((void *) &X, NULL) ;                                  \
+     132             :     GrB_free (&L) ;                                                     \
+     133             :     GrB_free (&L_prev) ;                                                \
+     134             :     if (sanitize) GrB_free (&S) ;                                       \
+     135             :     GrB_free (&AT) ;                                                    \
+     136             : }
+     137             : 
+     138             : #include <LAGraph.h>
+     139             : #include <LAGraphX.h>
+     140             : #include "LG_internal.h"
+     141             : 
+     142             : //****************************************************************************
+     143          12 : int LAGraph_cdlp
+     144             : (
+     145             :     GrB_Vector *CDLP_handle, // output vector
+     146             :     const GrB_Matrix A,      // input matrix
+     147             :     bool symmetric,          // denote whether the matrix is symmetric
+     148             :     bool sanitize,           // if true, ensure A is binary
+     149             :     int itermax,             // max number of iterations,
+     150             :     double *t,               // t [0] = sanitize time, t [1] = cdlp time,
+     151             :                              // in seconds
+     152             :     char *msg
+     153             : )
+     154             : {
+     155             :     GrB_Info info;
+     156          12 :     LG_CLEAR_MSG ;
+     157             : 
+     158             :     // Diagonal label matrix
+     159          12 :     GrB_Matrix L = NULL;
+     160          12 :     GrB_Matrix L_prev = NULL;
+     161             :     // Source adjacency matrix
+     162          12 :     GrB_Matrix S = NULL;
+     163             :     // Transposed matrix for the unsymmetric case
+     164          12 :     GrB_Matrix AT = NULL;
+     165             :     // Result CDLP vector
+     166          12 :     GrB_Vector CDLP = NULL;
+     167             : 
+     168             :     // Arrays holding extracted tuples if the matrix needs to be copied
+     169          12 :     GrB_Index *AI = NULL;
+     170          12 :     GrB_Index *AJ = NULL;
+     171          12 :     GrB_Index *AX = NULL;
+     172             :     // Arrays holding extracted tuples during the algorithm
+     173          12 :     GrB_Index *I = NULL;
+     174          12 :     GrB_Index *X = NULL;
+     175             : 
+     176             :     //--------------------------------------------------------------------------
+     177             :     // check inputs
+     178             :     //--------------------------------------------------------------------------
+     179             : 
+     180          12 :     if (CDLP_handle == NULL || t == NULL)
+     181             :     {
+     182           1 :         return GrB_NULL_POINTER;
+     183             :     }
+     184             : 
+     185             :     //--------------------------------------------------------------------------
+     186             :     // ensure input is binary and has no self-edges
+     187             :     //--------------------------------------------------------------------------
+     188             : 
+     189          11 :     t [0] = 0;         // sanitize time
+     190          11 :     t [1] = 0;         // CDLP time
+     191             : 
+     192             :     // n = size of A (# of nodes in the graph)
+     193             :     // nz = # of non-zero elements in the matrix
+     194             :     // nnz = # of non-zero elements used in the computations
+     195             :     //   (twice as many for directed graphs)
+     196             :     GrB_Index n, nz, nnz;
+     197          11 :     GRB_TRY (GrB_Matrix_nrows(&n, A))
+     198          11 :     GRB_TRY (GrB_Matrix_nvals(&nz, A))
+     199          11 :     if (!symmetric)
+     200             :     {
+     201           1 :         nnz = 2 * nz;
+     202             :     }
+     203             :     else
+     204             :     {
+     205          10 :         nnz = nz;
+     206             :     }
+     207             : 
+     208          11 :     if (sanitize)
+     209             :     {
+     210           4 :         t [0] = LAGraph_WallClockTime ( ) ;
+     211             : 
+     212           4 :         LAGRAPH_TRY (LAGraph_Malloc ((void **) &AI, nz, sizeof(GrB_Index),msg));
+     213           4 :         LAGRAPH_TRY (LAGraph_Malloc ((void **) &AJ, nz, sizeof(GrB_Index),msg));
+     214           4 :         GRB_TRY (GrB_Matrix_extractTuples_UINT64(AI, AJ, GrB_NULL, &nz, A))
+     215             : 
+     216           4 :         LAGRAPH_TRY (LAGraph_Calloc ((void **) &AX, nz, sizeof(GrB_Index),msg));
+     217           4 :         GRB_TRY (GrB_Matrix_new(&S, GrB_UINT64, n, n));
+     218           4 :         GRB_TRY (GrB_Matrix_build(S, AI, AJ, AX, nz, GrB_PLUS_UINT64));
+     219             : 
+     220           4 :         t [0] = LAGraph_WallClockTime ( ) - t [0] ;
+     221             :     }
+     222             :     else
+     223             :     {
+     224             :         // Use the input as-is, and assume it is UINT64(!) with no self edges.
+     225             :         // Results are undefined if this condition does not hold.
+     226           7 :         S = A;
+     227             :     }
+     228             : 
+     229          11 :     t [1] = LAGraph_WallClockTime ( ) ;
+     230             : 
+     231             : #ifdef LAGRAPH_SUITESPARSE
+     232          11 :     GxB_Format_Value A_format = -1, global_format = -1 ;
+     233          11 :     GRB_TRY (GxB_get(A, GxB_FORMAT, &A_format))
+     234          11 :     GRB_TRY (GxB_get(GxB_FORMAT, &global_format))
+     235          11 :     if (A_format != GxB_BY_ROW || global_format != GxB_BY_ROW)
+     236             :     {
+     237           1 :         LG_FREE_ALL;
+     238           1 :         return (GrB_INVALID_VALUE) ;
+     239             :     }
+     240             : #endif
+     241             : 
+     242             :     // Initialize L with diagonal elements 1..n
+     243          10 :     LAGRAPH_TRY (LAGraph_Malloc ((void **) &I, n, sizeof (GrB_Index), msg)) ;
+     244          10 :     LAGRAPH_TRY (LAGraph_Malloc ((void **) &X, n, sizeof (GrB_Index), msg)) ;
+     245        3304 :     for (GrB_Index i = 0; i < n; i++) {
+     246        3294 :         I[i] = i;
+     247        3294 :         X[i] = i;
+     248             :     }
+     249          10 :     GRB_TRY (GrB_Matrix_new (&L, GrB_UINT64, n, n)) ;
+     250          10 :     GRB_TRY (GrB_Matrix_build (L, I, I, X, n, GrB_PLUS_UINT64)) ;
+     251          10 :     LAGraph_Free ((void **) &I, NULL) ;
+     252          10 :     LAGraph_Free ((void **) &X, NULL) ;
+     253             : 
+     254             :     // Initialize matrix for storing previous labels
+     255          10 :     GRB_TRY (GrB_Matrix_new(&L_prev, GrB_UINT64, n, n))
+     256             : 
+     257          10 :     if (!symmetric)
+     258             :     {
+     259             :         // compute AT for the unsymmetric case as it will be used
+     260             :         // to compute A' = A' min.2nd L in each iteration
+     261           1 :         GRB_TRY (GrB_Matrix_new (&AT, GrB_UINT64, n, n)) ;
+     262           1 :         GRB_TRY (GrB_transpose (AT, NULL, NULL, A, NULL)) ;
+     263             :     }
+     264             : 
+     265         259 :     for (int iteration = 0; iteration < itermax; iteration++)
+     266             :     {
+     267             :         // Initialize data structures for extraction from 'AL_in' and (for directed graphs) 'AL_out'
+     268         257 :         LAGRAPH_TRY (LAGraph_Malloc((void **) &I, nnz, sizeof(GrB_Index), msg));
+     269         257 :         LAGRAPH_TRY (LAGraph_Malloc((void **) &X, nnz, sizeof(GrB_Index), msg));
+     270             : 
+     271             :         // A = A min.2nd L
+     272             :         // (using the "push" (saxpy) method)
+     273         257 :         GRB_TRY (GrB_mxm(S, GrB_NULL, GrB_NULL,
+     274             :                            GrB_MIN_SECOND_SEMIRING_UINT64, S, L, NULL));
+     275         257 :         GRB_TRY (GrB_Matrix_extractTuples_UINT64(I, GrB_NULL, X, &nz, S));
+     276             : 
+     277         257 :         if (!symmetric)
+     278             :         {
+     279             :             // A' = A' min.2nd L
+     280             :             // (using the "push" (saxpy) method)
+     281           6 :             GRB_TRY (GrB_mxm(AT, GrB_NULL, GrB_NULL,
+     282             :                                GrB_MIN_SECOND_SEMIRING_UINT64, AT, L, NULL));
+     283           6 :             GRB_TRY (GrB_Matrix_extractTuples_UINT64(&I[nz],
+     284             :                                                        GrB_NULL, &X[nz], &nz, AT));
+     285             :         }
+     286             : 
+     287         257 :         LG_msort2((int64_t *) I, (int64_t *) X, nnz, NULL);
+     288             : 
+     289             :         // save current labels for comparison by swapping L and L_prev
+     290         257 :         GrB_Matrix L_swap = L;
+     291         257 :         L = L_prev;
+     292         257 :         L_prev = L_swap;
+     293             : 
+     294         257 :         GrB_Index mode_value = -1;
+     295         257 :         GrB_Index mode_length = 0;
+     296         257 :         GrB_Index run_length = 1;
+     297             : 
+     298             :         // I[k] is the current row index
+     299             :         // X[k] is the current value
+     300             :         // we iterate in range 1..nnz and use the last index (nnz) to process the last row of the matrix
+     301     1524968 :         for (GrB_Index k = 1; k <= nnz; k++)
+     302             :         {
+     303             :             // check if we have a reason to recompute the mode value
+     304     1524711 :             if (k == nnz           // we surpassed the last element
+     305     1524454 :                 || I[k-1] != I[k]  // the row index has changed
+     306     1474530 :                 || X[k-1] != X[k]) // the run value has changed
+     307             :             {
+     308      260160 :                 if (run_length > mode_length)
+     309             :                 {
+     310       84859 :                     mode_value = X[k-1];
+     311       84859 :                     mode_length = run_length;
+     312             :                 }
+     313      260160 :                 run_length = 0;
+     314             :             }
+     315     1524711 :             run_length++;
+     316             : 
+     317             :             // check if we passed a row
+     318     1524711 :             if (k == nnz           // we surpassed the last element
+     319     1524454 :                 || I[k-1] != I[k]) // or the row index has changed
+     320             :             {
+     321       50181 :                 GrB_Matrix_setElement(L, mode_value, I[k-1], I[k-1]);
+     322       50181 :                 mode_length = 0;
+     323             :             }
+     324             :         }
+     325             : 
+     326         257 :         LAGraph_Free ((void **) &I, NULL) ;
+     327         257 :         LAGraph_Free ((void **) &X, NULL) ;
+     328             : 
+     329             :         bool isequal;
+     330         257 :         LAGraph_Matrix_IsEqual (&isequal, L_prev, L, NULL);
+     331         257 :         if (isequal) {
+     332           8 :             break;
+     333             :         }
+     334             :     }
+     335             : 
+     336             :     //--------------------------------------------------------------------------
+     337             :     // extract final labels to the result vector
+     338             :     //--------------------------------------------------------------------------
+     339             : 
+     340          10 :     GRB_TRY (GrB_Vector_new(&CDLP, GrB_UINT64, n))
+     341        3304 :     for (GrB_Index i = 0; i < n; i++)
+     342             :     {
+     343             :         uint64_t x;
+     344        3294 :         GRB_TRY (GrB_Matrix_extractElement(&x, L, i, i))
+     345        3294 :         GRB_TRY (GrB_Vector_setElement(CDLP, x, i))
+     346             :     }
+     347             : 
+     348             :     //--------------------------------------------------------------------------
+     349             :     // free workspace and return result
+     350             :     //--------------------------------------------------------------------------
+     351             : 
+     352          10 :     (*CDLP_handle) = CDLP;
+     353          10 :     CDLP = NULL;            // set to NULL so LG_FREE_ALL doesn't free it
+     354          10 :     LG_FREE_ALL;
+     355             : 
+     356          10 :     t [1] = LAGraph_WallClockTime ( ) - t [1] ;
+     357             : 
+     358          10 :     return (GrB_SUCCESS);
+     359             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_dnn.c.func-sort-c.html b/experimental/algorithm/LAGraph_dnn.c.func-sort-c.html new file mode 100644 index 0000000000..b819d99a9e --- /dev/null +++ b/experimental/algorithm/LAGraph_dnn.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_dnn.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_dnn.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1616100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_dnn2
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_dnn.c.func.html b/experimental/algorithm/LAGraph_dnn.c.func.html new file mode 100644 index 0000000000..376563e66b --- /dev/null +++ b/experimental/algorithm/LAGraph_dnn.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_dnn.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_dnn.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1616100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_dnn2
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_dnn.c.gcov.html b/experimental/algorithm/LAGraph_dnn.c.gcov.html new file mode 100644 index 0000000000..afcb9e42bb --- /dev/null +++ b/experimental/algorithm/LAGraph_dnn.c.gcov.html @@ -0,0 +1,191 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_dnn.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_dnn.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1616100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_dnn: sparse deep neural network
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // LAGraph_dnn: sparse deep neural network.
+      19             : // Based on inferenceReLUvec.m by Jeremy Kepner, MIT.
+      20             : 
+      21             : // Performs ReLU inference using input feature vectors Y0.
+      22             : 
+      23             : // See http://graphchallenge.org/ for a description of the algorithm.
+      24             : 
+      25             : // On input, Y0 is the initial feature vectors, of size nfeatures-by-nneurons.
+      26             : // This format uses the graph convention that A(i,j) is the edge (i,j).
+      27             : // Each row of Y0 is a single feature.
+      28             : 
+      29             : // W is an array of size nlayers of sparse matrices.  Each W[layer] matrix has
+      30             : // the same size: nneurons-by-nneurons.  W[layer] represents the DNN weights
+      31             : // for that layer.
+      32             : 
+      33             : // The Bias[layer] matrices are diagonal, and the same size as W[layer].
+      34             : 
+      35             : // All matrices should have type GrB_FP32; the method will be very slow
+      36             : // otherwise.
+      37             : 
+      38             : // On output, Y is the computed result, of the same size as Y0.
+      39             : 
+      40             : #define LG_FREE_ALL         \
+      41             : {                           \
+      42             :     GrB_free (&Y) ;         \
+      43             : }
+      44             : 
+      45             : #include "LG_internal.h"
+      46             : #include "LAGraphX.h"
+      47             : 
+      48             : //****************************************************************************
+      49           2 : GrB_Info LAGraph_dnn    // returns GrB_SUCCESS if successful
+      50             : (
+      51             :     // output
+      52             :     GrB_Matrix *Yhandle,    // Y, created on output
+      53             :     // input: not modified
+      54             :     GrB_Matrix *W,      // W [0..nlayers-1], each nneurons-by-nneurons
+      55             :     GrB_Matrix *Bias,   // Bias [0..nlayers-1], diagonal nneurons-by-nneurons
+      56             :     int nlayers,        // # of layers
+      57             :     GrB_Matrix Y0       // input features: nfeatures-by-nneurons
+      58             : )
+      59             : {
+      60             :     GrB_Info info ;
+      61           2 :     char *msg = NULL ;
+      62             : 
+      63             :     //--------------------------------------------------------------------------
+      64             :     // check inputs
+      65             :     //--------------------------------------------------------------------------
+      66             : 
+      67           2 :     if (Yhandle == NULL || W == NULL || Bias == NULL || Y0 == NULL)
+      68             :     {
+      69           1 :         return (GrB_NULL_POINTER) ;
+      70             :     }
+      71             : 
+      72             :     //--------------------------------------------------------------------------
+      73             :     // create the output matrix Y
+      74             :     //--------------------------------------------------------------------------
+      75             : 
+      76           1 :     GrB_Matrix Y = NULL ;
+      77           1 :     (*Yhandle) = NULL ;
+      78             :     GrB_Index nfeatures, nneurons ;
+      79           1 :     GRB_TRY (GrB_Matrix_nrows (&nfeatures, Y0)) ;
+      80           1 :     GRB_TRY (GrB_Matrix_ncols (&nneurons,  Y0)) ;
+      81           1 :     GRB_TRY (GrB_Matrix_new (&Y, GrB_FP32, nfeatures, nneurons)) ;
+      82             : 
+      83             :     //--------------------------------------------------------------------------
+      84             :     // propagate the features through the neuron layers
+      85             :     //--------------------------------------------------------------------------
+      86             : 
+      87          31 :     for (int layer = 0 ; layer < nlayers ; layer++)
+      88             :     {
+      89             :         // Y = Y * W [layer], using the conventional PLUS_TIMES semiring
+      90          30 :         GRB_TRY (GrB_mxm (Y, NULL, NULL, GrB_PLUS_TIMES_SEMIRING_FP32,
+      91             :             ((layer == 0) ? Y0 : Y), W [layer], NULL)) ;
+      92             : 
+      93             :         // Y = Y * Bias [layer], using the MIN_PLUS semiring.  This computes
+      94             :         // Y(i,j) += Bias [layer] (j,j) for each entry Y(i,j).  It does not
+      95             :         // introduce any new entries in Y.  The MIN monoid is not actually used
+      96             :         // since Bias [layer] is a diagonal matrix.  The prior version used
+      97             :         // a PLUS_PLUS semiring, which also works but is not a GrB built-in.
+      98          30 :         GRB_TRY (GrB_mxm (Y, NULL, NULL, GrB_MIN_PLUS_SEMIRING_FP32, Y,
+      99             :             Bias [layer], NULL)) ;
+     100             : 
+     101             :         // delete entries from Y: keep only those entries greater than zero
+     102          30 :         GRB_TRY (GrB_select (Y, NULL, NULL, GrB_VALUEGT_FP32, Y, (float) 0,
+     103             :             NULL));
+     104             : 
+     105             :         // threshold maximum values: Y = min (Y, 32)
+     106          30 :         GRB_TRY (GrB_apply (Y, NULL, NULL, GrB_MIN_FP32, Y, (float) 32, NULL)) ;
+     107             :     }
+     108             : 
+     109             :     //--------------------------------------------------------------------------
+     110             :     // return result
+     111             :     //--------------------------------------------------------------------------
+     112             : 
+     113           1 :     (*Yhandle) = Y ;
+     114           1 :     return (GrB_SUCCESS) ;
+     115             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_lcc.c.func-sort-c.html b/experimental/algorithm/LAGraph_lcc.c.func-sort-c.html new file mode 100644 index 0000000000..5ec695c735 --- /dev/null +++ b/experimental/algorithm/LAGraph_lcc.c.func-sort-c.html @@ -0,0 +1,84 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_lcc.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_lcc.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:6767100.0 %
Date:2024-08-29 20:08:04Functions:33100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_lcc12
LAGraph_comb_dir_fp6467
LAGraph_comb_undir_fp643227
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_lcc.c.func.html b/experimental/algorithm/LAGraph_lcc.c.func.html new file mode 100644 index 0000000000..8c92366e64 --- /dev/null +++ b/experimental/algorithm/LAGraph_lcc.c.func.html @@ -0,0 +1,84 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_lcc.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_lcc.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:6767100.0 %
Date:2024-08-29 20:08:04Functions:33100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_comb_dir_fp6467
LAGraph_comb_undir_fp643227
LAGraph_lcc12
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_lcc.c.gcov.html b/experimental/algorithm/LAGraph_lcc.c.gcov.html new file mode 100644 index 0000000000..3e02818157 --- /dev/null +++ b/experimental/algorithm/LAGraph_lcc.c.gcov.html @@ -0,0 +1,374 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_lcc.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_lcc.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:6767100.0 %
Date:2024-08-29 20:08:04Functions:33100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_lcc: local clustering coefficient
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Gabor Szarnyas and Balint Hegyi, Budapest University of
+      15             : // Technology and Economics (with accented characters: G\'{a}bor Sz\'{a}rnyas
+      16             : // and B\'{a}lint Hegyi, using LaTeX syntax).
+      17             : // https://inf.mit.bme.hu/en/members/szarnyasg .
+      18             : // Modified by Timothy A. Davis, Texas A&M University
+      19             : 
+      20             : //------------------------------------------------------------------------------
+      21             : 
+      22             : // This function was originally written for the LDBC Graphalytics benchmark,
+      23             : // at https://graphalytics.org/ .
+      24             : 
+      25             : // The local clustering coefficient is a measure for each node of a graph.
+      26             : // Its definition is fully described in the following document:
+      27             : // https://ldbc.github.io/ldbc_graphalytics_docs/graphalytics_spec.pdf
+      28             : 
+      29             : // For each node v, the lcc(v) is the ratio between the number of edges between
+      30             : // neighbors of the node v, and the maximum possible number of edges between
+      31             : // these neighbors.  If a node v has fewer than 2 neighbors, then its
+      32             : // coefficient is defined as zero, and the vth entry does not appear in the
+      33             : // sparse vector LCC returned.
+      34             : 
+      35             : // Let N_in(v)  = the set of nodes u such that (u,v) is an edge.
+      36             : // Let N_out(v) = the set of nodes u such that (v,u) is an edge.
+      37             : // Let N(v) = union (N_in(v), N_out(v)).
+      38             : // Then the metric lcc(v) is defined as:
+      39             : 
+      40             : // lcc(v) = (sum for all u in N(v) of |intersection (N(v), N_out(u))) /
+      41             : //          ( |N(v)| * (|N(v)|-1) )
+      42             : 
+      43             : // That is, for directed graphs, the set of neighbors N(v) is found without
+      44             : // taking directions into account, but a node u that has both an edge (u,v) and
+      45             : // (v,u) is counted just once.  However, edge directions are enforced when
+      46             : // considering two nodes u1 and u2 that are both in N(v), i.e. when counting
+      47             : // the number of edges between neighbors, (u,v) and (v,u) are counted as two.
+      48             : // To account for this, the maximum possible number of edges for vertex v is
+      49             : // determined as the 2-combination of |N(v)| for undirected graphs and as the
+      50             : // 2-permutation of |N(v)| for directed graphs.
+      51             : 
+      52             : // The input matrix A must be square.  If A is known to be binary (with all
+      53             : // explicit edge weights equal to 1), then sanitize can be false.  This is the
+      54             : // case for the LDBC benchmark.
+      55             : 
+      56             : // Otherwise, if sanitize is true, edge weights of A are ignored and only the
+      57             : // structure of A is used.  This step takes extra time and memory to sanitize the
+      58             : // input matrix A.  For a fair comparison in the LDBC benchmark, sanitize
+      59             : // should be false.
+      60             : 
+      61             : // Results are undefined if sanitize is false, and the matrix A has any entries
+      62             : // not equal to 1 (even zero-weight edges are not allowed), or if it has self
+      63             : // edges.
+      64             : 
+      65             : #define LG_FREE_ALL                 \
+      66             : {                                   \
+      67             :     GrB_free (&A2) ;                \
+      68             :     GrB_free (&C2) ;                \
+      69             :     GrB_free (&CL) ;                \
+      70             :     GrB_free (&U) ;                 \
+      71             :     GrB_free (&W) ;                 \
+      72             :     GrB_free (&LCC) ;               \
+      73             :     GrB_free (&LAGraph_COMB_DIR_FP64) ;                 \
+      74             :     GrB_free (&LAGraph_COMB_UNDIR_FP64) ;                 \
+      75             : }
+      76             : 
+      77             : #include "LG_internal.h"
+      78             : #include <LAGraph.h>
+      79             : #include <LAGraphX.h>
+      80             : 
+      81             : //------------------------------------------------------------------------------
+      82             : 
+      83             : #define F_UNARY(f)  ((void (*)(void *, const void *)) f)
+      84             : 
+      85             : // z = x * (x - 1), used by LAGraph_lcc.
+      86             : // This operator calculates the 2-permutation of d(v).
+      87          67 : void LAGraph_comb_dir_fp64
+      88             : (
+      89             :     void *z,
+      90             :     const void *x
+      91             : )
+      92             : {
+      93          67 :     double xd = *(double *) x ;
+      94          67 :     double *zd = (double *) z ;
+      95          67 :     (*zd) = ((xd) * (xd - 1)) ;
+      96          67 : }
+      97             : 
+      98             : // z = x * (x - 1) / 2, used by LAGraph_lcc.
+      99             : // This operator calculates the 2-combination of d(v).
+     100        3227 : void LAGraph_comb_undir_fp64
+     101             : (
+     102             :     void *z,
+     103             :     const void *x
+     104             : )
+     105             : {
+     106        3227 :     double xd = *(double *) x ;
+     107        3227 :     double *zd = (double *) z ;
+     108        3227 :     (*zd) = ((xd) * (xd - 1)) / 2;
+     109        3227 : }
+     110             : 
+     111             : //------------------------------------------------------------------------------
+     112             : 
+     113          12 : int LAGraph_lcc            // compute lcc for all nodes in A
+     114             : (
+     115             :     GrB_Vector *LCC_handle,     // output vector
+     116             :     const GrB_Matrix A,         // input matrix
+     117             :     bool symmetric,             // if true, the matrix is symmetric
+     118             :     bool sanitize,              // if true, ensure A is binary
+     119             :     double t [2],               // t [0] = sanitize time, t [1] = lcc time,
+     120             :                                 // in seconds
+     121             :     char *msg
+     122             : )
+     123             : {
+     124             : 
+     125             :     //--------------------------------------------------------------------------
+     126             :     // check inputs
+     127             :     //--------------------------------------------------------------------------
+     128             : 
+     129          12 :     LG_CLEAR_MSG ;
+     130          12 :     if (LCC_handle == NULL)
+     131             :     {
+     132           1 :         return (GrB_NULL_POINTER) ;
+     133             :     }
+     134             : 
+     135          11 :     GrB_Matrix C = NULL, CL = NULL, S = NULL, U = NULL ;
+     136          11 :     GrB_Vector W = NULL, LCC = NULL ; 
+     137          11 :     GrB_Matrix A2 = NULL, C2 = NULL ;
+     138          11 :     GrB_UnaryOp LAGraph_COMB_DIR_FP64 = NULL ;
+     139          11 :     GrB_UnaryOp LAGraph_COMB_UNDIR_FP64 = NULL ;
+     140             :     GrB_Info info ;
+     141             : 
+     142             : #if !LAGRAPH_SUITESPARSE
+     143             :     LG_ASSERT (false, GrB_NOT_IMPLEMENTED) ;
+     144             : #else
+     145             : 
+     146             :     // n = size of A (# of nodes in the graph)
+     147             :     GrB_Index n ;
+     148          11 :     GRB_TRY (GrB_Matrix_nrows (&n, A)) ;
+     149             : #if LAGRAPH_SUITESPARSE
+     150             :     GxB_Format_Value fmt ;
+     151          11 :     GRB_TRY (GxB_get (A, GxB_FORMAT, &fmt)) ;
+     152          11 :     if (fmt != GxB_BY_ROW)
+     153             :     {
+     154           1 :         return (GrB_INVALID_VALUE) ;
+     155             :     }
+     156             : #endif
+     157             : 
+     158             :     //--------------------------------------------------------------------------
+     159             :     // ensure input is binary and has no self-edges
+     160             :     //--------------------------------------------------------------------------
+     161             : 
+     162          10 :     t [0] = 0 ;         // sanitize time
+     163          10 :     t [1] = 0 ;         // LCC time
+     164             : 
+     165             :     // fixme: use operators that ignore the values of A
+     166          10 :     if (sanitize)
+     167             :     {
+     168           3 :         t [0] = LAGraph_WallClockTime ( ) ;
+     169             : 
+     170             :         // S = binary structure of A
+     171           3 :         GRB_TRY (GrB_Matrix_new (&A2, GrB_FP64, n, n)) ;
+     172           3 :         GRB_TRY (GrB_apply (A2, NULL, NULL, GrB_ONEB_FP64, A, 0, NULL)) ;
+     173             : 
+     174             :         // remove all self edges
+     175           3 :         GRB_TRY (GrB_select (A2, NULL, NULL, GrB_OFFDIAG, A2, 0, NULL)) ;
+     176           3 :         t [0] = LAGraph_WallClockTime ( ) - t [0] ;
+     177           3 :         S = A2 ;
+     178             :     }
+     179             :     else
+     180             :     {
+     181             :         // Use the input as-is, and assume it is binary with no self edges.
+     182             :         // Results are undefined if this condition does not hold.
+     183           7 :         S = A ;
+     184             :     }
+     185             : 
+     186          10 :     t [1] = LAGraph_WallClockTime ( ) ;
+     187             : 
+     188             :     //--------------------------------------------------------------------------
+     189             :     // create the operators for LAGraph_lcc
+     190             :     //--------------------------------------------------------------------------
+     191             : 
+     192          10 :     GRB_TRY (GrB_UnaryOp_new (&LAGraph_COMB_DIR_FP64,
+     193             :                                  F_UNARY (LAGraph_comb_dir_fp64),
+     194             :                                  GrB_FP64, GrB_FP64)) ;
+     195             : 
+     196          10 :     GRB_TRY (GrB_UnaryOp_new (&LAGraph_COMB_UNDIR_FP64,
+     197             :                                  F_UNARY (LAGraph_comb_undir_fp64),
+     198             :                                  GrB_FP64, GrB_FP64)) ;
+     199             : 
+     200          10 :     GRB_TRY (GrB_Matrix_new (&U, GrB_UINT32, n, n)) ;
+     201             : 
+     202          10 :     if (symmetric)
+     203             :     {
+     204           9 :         C = S ;
+     205             : 
+     206             :         //----------------------------------------------------------------------
+     207             :         // U = triu(C)
+     208             :         //----------------------------------------------------------------------
+     209             : 
+     210           9 :         GRB_TRY (GxB_select (U, NULL, NULL, GxB_TRIU, C, NULL, NULL)) ;
+     211             : 
+     212             :     }
+     213             :     else
+     214             :     {
+     215           1 :         GrB_Matrix AT = NULL, D = NULL ;
+     216             : 
+     217           1 :         GRB_TRY (GrB_Matrix_new (&AT, GrB_FP64, n, n)) ;
+     218           1 :         GRB_TRY (GrB_transpose (AT, NULL, NULL, S, NULL)) ;
+     219             : 
+     220             :         //----------------------------------------------------------------------
+     221             :         // C = A \/ A' to create an undirected graph C
+     222             :         //----------------------------------------------------------------------
+     223             : 
+     224           1 :         GRB_TRY (GrB_Matrix_new (&C2, GrB_FP64, n, n)) ;
+     225           1 :         C = C2 ;
+     226           1 :         GRB_TRY (GrB_eWiseAdd (C, NULL, NULL, GrB_LOR, S, AT, NULL)) ;
+     227             : 
+     228             :         //----------------------------------------------------------------------
+     229             :         // D = A + A' to create an undirected multigraph D
+     230             :         //----------------------------------------------------------------------
+     231             : 
+     232           1 :         GRB_TRY (GrB_Matrix_new (&D, GrB_FP64, n, n)) ;
+     233           1 :         GRB_TRY (GrB_eWiseAdd (D, NULL, NULL, GrB_PLUS_FP64, S, AT, NULL)) ;
+     234             : 
+     235           1 :         GrB_free (&AT) ;
+     236             : 
+     237             :         //----------------------------------------------------------------------
+     238             :         // U = triu(D)
+     239             :         //----------------------------------------------------------------------
+     240             : 
+     241             :         // note that L=U' since D is symmetric
+     242           1 :         GRB_TRY (GxB_select (U, NULL, NULL, GxB_TRIU, D, NULL, NULL)) ;
+     243           1 :         GrB_free (&D) ;
+     244             :     }
+     245             : 
+     246             :     //--------------------------------------------------------------------------
+     247             :     // Find wedges of each node
+     248             :     //--------------------------------------------------------------------------
+     249             : 
+     250             :     // W(i) = sum (C (i,:))
+     251          10 :     GRB_TRY (GrB_Vector_new (&W, GrB_FP64, n)) ;
+     252          10 :     GRB_TRY (GrB_reduce (W, NULL, NULL, GrB_PLUS_FP64, C, NULL)) ;
+     253             : 
+     254             :     // Compute vector W defining the number of wedges per vertex
+     255          10 :     if (symmetric)
+     256             :     {
+     257             :         // the graph is undirected
+     258           9 :         GRB_TRY (GrB_apply(W, NULL, NULL, LAGraph_COMB_UNDIR_FP64, W, NULL));
+     259             :     }
+     260             :     else
+     261             :     {
+     262             :         // the graph is directed
+     263           1 :         GRB_TRY (GrB_apply(W, NULL, NULL, LAGraph_COMB_DIR_FP64, W, NULL)) ;
+     264             :     }
+     265             : 
+     266             :     //--------------------------------------------------------------------------
+     267             :     // Calculate triangles
+     268             :     //--------------------------------------------------------------------------
+     269             : 
+     270             :     // CL<C> = C*L = C*U' using a masked dot product
+     271          10 :     GRB_TRY (GrB_Matrix_new (&CL, GrB_FP64, n, n)) ;
+     272          10 :     GRB_TRY (GrB_mxm (CL, C, NULL, GrB_PLUS_TIMES_SEMIRING_FP64, C, U,
+     273             :                          GrB_DESC_T1));
+     274          10 :     GrB_free (&U) ; U = NULL;
+     275             : 
+     276             :     //--------------------------------------------------------------------------
+     277             :     // Calculate LCC
+     278             :     //--------------------------------------------------------------------------
+     279             : 
+     280             :     // LCC(i) = sum (CL (i,:)) = # of triangles at each node
+     281          10 :     GRB_TRY (GrB_Vector_new (&LCC, GrB_FP64, n)) ;
+     282          10 :     GRB_TRY (GrB_reduce (LCC, NULL, NULL, GrB_PLUS_FP64, CL, NULL)) ;
+     283          10 :     GrB_free (&CL) ; CL = NULL;
+     284             : 
+     285             :     // LCC = LCC ./ W
+     286          10 :     GRB_TRY (GrB_eWiseMult (LCC, NULL, NULL, GrB_DIV_FP64, LCC, W, NULL)) ;
+     287             : 
+     288             :     //--------------------------------------------------------------------------
+     289             :     // free workspace and return result
+     290             :     //--------------------------------------------------------------------------
+     291             : 
+     292          10 :     (*LCC_handle) = LCC ; LCC = NULL ;
+     293             : 
+     294          10 :     LG_FREE_ALL ;
+     295          10 :     t [1] = LAGraph_WallClockTime ( ) - t [1] ;
+     296          10 :     return (GrB_SUCCESS) ;
+     297             : #endif
+     298             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_msf.c.func-sort-c.html b/experimental/algorithm/LAGraph_msf.c.func-sort-c.html new file mode 100644 index 0000000000..d10e7422b3 --- /dev/null +++ b/experimental/algorithm/LAGraph_msf.c.func-sort-c.html @@ -0,0 +1,100 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_msf.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_msf.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:130130100.0 %
Date:2024-08-29 20:08:04Functions:77100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_msf12
Reduce_assign30
get_fst9771
get_snd16258
combine103852
f1192530
f2192530
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_msf.c.func.html b/experimental/algorithm/LAGraph_msf.c.func.html new file mode 100644 index 0000000000..a099e63558 --- /dev/null +++ b/experimental/algorithm/LAGraph_msf.c.func.html @@ -0,0 +1,100 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_msf.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_msf.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:130130100.0 %
Date:2024-08-29 20:08:04Functions:77100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_msf12
Reduce_assign30
combine103852
f1192530
f2192530
get_fst9771
get_snd16258
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_msf.c.gcov.html b/experimental/algorithm/LAGraph_msf.c.gcov.html new file mode 100644 index 0000000000..102e182be2 --- /dev/null +++ b/experimental/algorithm/LAGraph_msf.c.gcov.html @@ -0,0 +1,354 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_msf.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_msf.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:130130100.0 %
Date:2024-08-29 20:08:04Functions:77100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_msf.c
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Yongzhe Zhang (zyz915@gmail.com)
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : /**
+      19             :  * Code is based on Boruvka's minimum spanning forest algorithm
+      20             :  */
+      21             : 
+      22             : #define LG_FREE_ALL                                  \
+      23             : {                                                    \
+      24             :     GrB_free (&S);                                   \
+      25             :     GrB_free (&T);                                   \
+      26             :     free(I); free(V);                                \
+      27             :     free(SI); free(SJ); free(SX);                    \
+      28             :     free(parent); free(partner); free(weight);       \
+      29             :     GrB_free (&f);                      \
+      30             :     GrB_free (&i);                      \
+      31             :     GrB_free (&t);                      \
+      32             :     GrB_free (&edge);                   \
+      33             :     GrB_free (&cedge);                  \
+      34             :     GrB_free (&mask);                   \
+      35             :     GrB_free (&index);                  \
+      36             :     GrB_free (&comb);                   \
+      37             :     GrB_free (&combMin);                \
+      38             :     GrB_free (&fst);                    \
+      39             :     GrB_free (&snd);                    \
+      40             :     GrB_free (&s1);                     \
+      41             :     GrB_free (&s2);                     \
+      42             : }
+      43             : 
+      44             : #include "LG_internal.h"
+      45             : #include <LAGraph.h>
+      46             : #include <LAGraphX.h>
+      47             : 
+      48             : //****************************************************************************
+      49             : // encode each edge into a single uint64_t
+      50      103852 : static void combine (void *z, const void *x, const void *y)
+      51             : {
+      52      103852 :     *(uint64_t*)z = ((*(uint64_t*)x) << 32) + (*(uint64_t*)y);
+      53      103852 : }
+      54             : 
+      55        9771 : static void get_fst (void *y, const void *x)
+      56             : {
+      57        9771 :     *(uint64_t*)y = (*(uint64_t*)x) >> 32;
+      58        9771 : }
+      59             : 
+      60       16258 : static void get_snd (void *y, const void *x)
+      61             : {
+      62       16258 :     *(uint64_t*)y = (*(uint64_t*)x) & INT_MAX;
+      63       16258 : }
+      64             : 
+      65             : //****************************************************************************
+      66             : // w[index[i]] = min(w[index[i]], s[i]) for i in [0..n-1]
+      67          30 : static GrB_Info Reduce_assign (GrB_Vector w,
+      68             :         GrB_Vector s, GrB_Index *index, GrB_Index n)
+      69             : {
+      70          30 :     GrB_Index *mem = (GrB_Index*) malloc(sizeof(GrB_Index) * n * 3);
+      71          30 :     GrB_Index *ind = mem, *sval = mem + n, *wval = sval + n;
+      72          30 :     GrB_Vector_extractTuples(ind, wval, &n, w);
+      73          30 :     GrB_Vector_extractTuples(ind, sval, &n, s);
+      74       13004 :     for (GrB_Index i = 0; i < n; i++)
+      75       12974 :         if (sval[i] < wval[index[i]])
+      76        6603 :             wval[index[i]] = sval[i];
+      77          30 :     GrB_Vector_clear(w);
+      78          30 :     GrB_Vector_build(w, ind, wval, n, GrB_PLUS_UINT64);
+      79          30 :     free(mem);
+      80          30 :     return GrB_SUCCESS;
+      81             : }
+      82             : 
+      83             : //****************************************************************************
+      84             : // global C arrays (for implementing various GxB_SelectOp)
+      85             : static GrB_Index *weight = NULL, *parent = NULL, *partner = NULL;
+      86             : 
+      87             : // generate solution:
+      88             : // for each element A(i, j), it is selected if
+      89             : //   1. weight[i] == A(i, j)    -- where weight[i] stores i's minimum edge weight
+      90             : //   2. parent[j] == partner[i] -- j belongs to the specified connected component
+      91      192530 : void f1 (bool *z, const void *x, GrB_Index i, GrB_Index j, const void *thunk)
+      92             : {
+      93      192530 :     uint64_t *aij = (uint64_t*) x;
+      94      192530 :     (*z) = (weight[i] == *aij) && (parent[j] == partner[i]);
+      95      192530 : }
+      96             : 
+      97             : // edge removal:
+      98             : // A(i, j) is removed when parent[i] == parent[j]
+      99      192530 : void f2 (bool *z, const void *x, GrB_Index i, GrB_Index j, const void *thunk)
+     100             : {
+     101      192530 :     (*z) = (parent[i] != parent[j]);
+     102      192530 : }
+     103             : 
+     104             : //****************************************************************************
+     105             : //****************************************************************************
+     106          12 : int LAGraph_msf
+     107             : (
+     108             :     GrB_Matrix *result, // output: an unsymmetrical matrix, the spanning forest
+     109             :     GrB_Matrix A,       // input matrix
+     110             :     bool sanitize,      // if true, ensure A is symmetric
+     111             :     char *msg
+     112             : )
+     113             : {
+     114             : 
+     115          12 :     LG_CLEAR_MSG ;
+     116             : 
+     117             : #if !LAGRAPH_SUITESPARSE
+     118             :     return (GrB_NOT_IMPLEMENTED) ;
+     119             : #else
+     120             : 
+     121             :     GrB_Info info;
+     122             :     GrB_Index n;
+     123          12 :     GrB_Matrix S = NULL, T = NULL;
+     124          12 :     GrB_Vector f = NULL, i = NULL, t = NULL,
+     125          12 :         edge = NULL, cedge = NULL, mask = NULL, index = NULL;
+     126          12 :     GrB_Index *I = NULL, *V = NULL, *SI = NULL, *SJ = NULL, *SX = NULL;
+     127             : 
+     128          12 :     GrB_BinaryOp comb = NULL;
+     129          12 :     GrB_Semiring combMin = NULL;
+     130          12 :     GrB_UnaryOp fst = NULL, snd = NULL;
+     131             : 
+     132          12 :     GrB_IndexUnaryOp s1 = NULL, s2 = NULL;
+     133          12 :     if (result == NULL || A == NULL) return (GrB_NULL_POINTER) ;
+     134             : 
+     135             :     GrB_Index ncols ;
+     136          11 :     GRB_TRY (GrB_Matrix_nrows (&n, A));
+     137          11 :     GRB_TRY (GrB_Matrix_ncols (&ncols, A));
+     138          11 :     if (n != ncols) return (GrB_DIMENSION_MISMATCH) ;
+     139             : 
+     140          10 :     if (sanitize)
+     141             :     {
+     142             :         // S = A+A'
+     143           1 :         GRB_TRY (GrB_Matrix_new (&S, GrB_UINT64, n, n));
+     144           1 :         GRB_TRY (GrB_eWiseAdd (S, 0, 0, GrB_PLUS_UINT64, A, A, GrB_DESC_T1));
+     145             :     }
+     146             :     else
+     147             :     {
+     148             :         // Use the input as-is, and assume it is GrB_UINT64 and symmetric
+     149           9 :         GRB_TRY (GrB_Matrix_dup (&S, A));
+     150             :     }
+     151             : 
+     152          10 :     GRB_TRY (GrB_Matrix_new (&T, GrB_UINT64, n, n));
+     153             : 
+     154          10 :     GRB_TRY (GrB_Vector_new (&t, GrB_UINT64, n));
+     155          10 :     GRB_TRY (GrB_Vector_new (&f, GrB_UINT64, n));
+     156          10 :     GRB_TRY (GrB_Vector_new (&i, GrB_UINT64, n));
+     157          10 :     GRB_TRY (GrB_Vector_new (&edge, GrB_UINT64, n));
+     158          10 :     GRB_TRY (GrB_Vector_new (&cedge, GrB_UINT64, n));
+     159          10 :     GRB_TRY (GrB_Vector_new (&mask, GrB_BOOL, n));
+     160          10 :     GRB_TRY (GrB_Vector_new (&index, GrB_UINT64, n));
+     161             : 
+     162             :     // temporary arrays
+     163          10 :     I = malloc (sizeof(GrB_Index) * n);
+     164          10 :     V = malloc (sizeof(GrB_Index) * n);
+     165          10 :     SI = malloc (sizeof(GrB_Index) * n * 2);
+     166          10 :     SJ = malloc (sizeof(GrB_Index) * n * 2);
+     167          10 :     SX = malloc (sizeof(GrB_Index) * n * 2);
+     168             : 
+     169             :     // global arrays
+     170          10 :     parent = malloc (sizeof(GrB_Index) * n);
+     171          10 :     weight = malloc (sizeof(GrB_Index) * n);
+     172          10 :     partner = malloc (sizeof(GrB_Index) * n);
+     173             : 
+     174             :     // prepare vectors
+     175        3304 :     for (GrB_Index i = 0; i < n; i++)
+     176        3294 :         I[i] = parent[i] = i;
+     177          10 :     GRB_TRY (GrB_Vector_build (f, I, parent, n, GrB_PLUS_UINT64));
+     178          10 :     GRB_TRY (GrB_assign (i, 0, 0, f, GrB_ALL, 0, 0));
+     179             : 
+     180             :     // semiring & monoid
+     181          10 :     GrB_Index inf = ((uint64_t) INT_MAX << 32) ^ INT_MAX;
+     182          10 :     GRB_TRY (GrB_BinaryOp_new (&comb, combine, GrB_UINT64, GrB_UINT64, GrB_UINT64));
+     183          10 :     GRB_TRY (GrB_Semiring_new (&combMin, GrB_MIN_MONOID_UINT64, comb));
+     184          10 :     GRB_TRY (GrB_UnaryOp_new (&fst, get_fst, GrB_UINT64, GrB_UINT64));
+     185          10 :     GRB_TRY (GrB_UnaryOp_new (&snd, get_snd, GrB_UINT64, GrB_UINT64));
+     186             : 
+     187             :     // GrB_SelectOp
+     188          10 :     GrB_IndexUnaryOp_new (&s1, (void *) f1, GrB_BOOL, GrB_UINT64, GrB_UINT64);
+     189          10 :     GrB_IndexUnaryOp_new (&s2, (void *) f2, GrB_BOOL, GrB_UINT64, GrB_UINT64);
+     190             : 
+     191             :     // the main computation
+     192          10 :     GrB_Index nvals, diff, ntuples = 0, num;
+     193          10 :     GRB_TRY (GrB_Matrix_nvals (&nvals, S));
+     194          15 :     for (int iters = 1; nvals > 0; iters++)
+     195             :     {
+     196             :         // every vertex points to a root vertex at the beginning
+     197             :         // edge[u] = u's minimum edge (weight and index are encoded together)
+     198          15 :         GRB_TRY (GrB_assign (edge, 0, 0, inf, GrB_ALL, 0, 0));
+     199          15 :         GRB_TRY (GrB_mxv (edge, 0, GrB_MIN_UINT64, combMin, S, f, 0));
+     200             :         // cedge[u] = children's minimum edge  | if u is a root
+     201             :         //          = (INT_MAX, u)             | otherwise
+     202          15 :         GRB_TRY (GrB_assign (t, 0, 0, (uint64_t) INT_MAX, GrB_ALL, 0, 0));
+     203          15 :         GRB_TRY (GrB_eWiseMult (cedge, 0, 0, comb, t, i, 0));
+     204          15 :         LG_TRY (Reduce_assign (cedge, edge, parent, n));
+     205             :         // if (f[u] == u) f[u] := snd(cedge[u])  -- the index part of the edge
+     206          15 :         GRB_TRY (GrB_eWiseMult (mask, 0, 0, GrB_EQ_UINT64, f, i, 0));
+     207          15 :         GRB_TRY (GrB_apply (f, mask, GrB_SECOND_UINT64, snd, cedge, 0));
+     208             :         // identify all the vertex pairs (u, v) where f[u] == v and f[v] == u
+     209             :         // and then select the minimum of u, v as the new root;
+     210             :         // if (f[f[i]] == i) f[i] = min(f[i], i)
+     211          15 :         GRB_TRY (GrB_Vector_extractTuples (I, V, &n, f));
+     212          15 :         GRB_TRY (GrB_extract (t, 0, 0, f, V, n, 0));
+     213          15 :         GRB_TRY (GrB_eWiseMult (mask, 0, 0, GrB_EQ_UINT64, i, t, 0));
+     214          15 :         GRB_TRY (GrB_assign (f, mask, GrB_MIN_UINT64, i, GrB_ALL, 0, 0));
+     215             : 
+     216             :         // five steps to generate the solution
+     217             :         // 1. new roots (f[i] == i) revise their entries in cedge
+     218          15 :         GRB_TRY (GrB_eWiseMult (mask, 0, 0, GrB_EQ_UINT64, i, f, 0));
+     219          15 :         GRB_TRY (GrB_assign (cedge, mask, 0, inf, GrB_ALL, 0, 0));
+     220             : 
+     221             :         // 2. every vertex tries to know whether one of its edges is selected
+     222          15 :         GRB_TRY (GrB_extract (t, 0, 0, cedge, parent, n, 0));
+     223          15 :         GRB_TRY (GrB_eWiseMult (mask ,0, 0, GrB_EQ_UINT64, edge, t, 0));
+     224             : 
+     225             :         // 3. each root picks a vertex from its children to generate the solution
+     226          15 :         GRB_TRY (GrB_assign (index, 0, 0, n, GrB_ALL, 0, 0));
+     227          15 :         GRB_TRY (GrB_assign (index, mask, 0, i, GrB_ALL, 0, 0));
+     228          15 :         GRB_TRY (GrB_assign (t, 0, 0, n, GrB_ALL, 0, 0));
+     229          15 :         LG_TRY (Reduce_assign (t, index, parent, n));
+     230          15 :         GRB_TRY (GrB_extract (index, 0, 0, t, parent, n, 0));
+     231          15 :         GRB_TRY (GrB_eWiseMult (mask ,0, 0, GrB_EQ_UINT64, i, index, 0));
+     232             : 
+     233             :         // 4. generate the select function (set the global pointers)
+     234          15 :         GRB_TRY (GrB_assign (t, 0, 0, inf, GrB_ALL, 0, 0));
+     235          15 :         GRB_TRY (GrB_apply (t, mask, 0, fst, edge, 0));
+     236          15 :         GRB_TRY (GrB_Vector_extractTuples (I, weight, &n, t));
+     237          15 :         GRB_TRY (GrB_assign (t, 0, 0, inf, GrB_ALL, 0, 0));
+     238          15 :         GRB_TRY (GrB_apply (t, mask, 0, snd, edge, 0));
+     239          15 :         GRB_TRY (GrB_Vector_extractTuples (I, partner, &n, t));
+     240          15 :         GRB_TRY (GrB_select (T, 0, 0, s1, S, 0, 0));
+     241          15 :         GRB_TRY (GrB_Vector_clear (t));
+     242             : 
+     243             :         // 5. the generated matrix may still have redundant edges
+     244             :         //    remove the duplicates by GrB_mxv() and store them as tuples
+     245          15 :         GRB_TRY (GrB_Vector_clear (edge));
+     246          15 :         GRB_TRY (GrB_mxv (edge, mask, GrB_MIN_UINT64, combMin, T, i, 0));
+     247          15 :         GRB_TRY (GrB_Vector_nvals (&num, edge));
+     248          15 :         GRB_TRY (GrB_apply (t, 0, 0, snd, edge, 0));
+     249          15 :         GRB_TRY (GrB_Vector_extractTuples (SI + ntuples, SJ + ntuples, &num, t));
+     250          15 :         GRB_TRY (GrB_apply (t, 0, 0, fst, edge, 0));
+     251          15 :         GRB_TRY (GrB_Vector_extractTuples (SI + ntuples, SX + ntuples, &num, t));
+     252          15 :         GRB_TRY (GrB_Vector_clear (t));
+     253          15 :         ntuples += num;
+     254             : 
+     255             :         // path halving until every vertex points on a root
+     256             :         do {
+     257          45 :             GRB_TRY (GrB_Vector_extractTuples (I, V, &n, f));
+     258          45 :             GRB_TRY (GrB_extract (t, 0, 0, f, V, n, 0));
+     259          45 :             GRB_TRY (GrB_eWiseMult (mask, 0, 0, GrB_NE_UINT64, f, t, 0));
+     260          45 :             GRB_TRY (GrB_assign (f, 0, 0, t, GrB_ALL, 0, 0));
+     261          45 :             GRB_TRY (GrB_reduce (&diff, 0, GrB_PLUS_MONOID_UINT64, mask, 0));
+     262          45 :         } while (diff != 0);
+     263             : 
+     264             :         // remove the edges in the same connected component
+     265          15 :         GRB_TRY (GrB_Vector_extractTuples (I, parent, &n, f));
+     266          15 :         GRB_TRY (GrB_select (S, 0, 0, s2, S, 0, 0));
+     267          15 :         GrB_Matrix_nvals (&nvals, S);
+     268          15 :         if (nvals == 0) break;
+     269             :     }
+     270          10 :     GRB_TRY (GrB_Matrix_clear (T));
+     271          10 :     GRB_TRY (GrB_Matrix_build (T, SI, SJ, SX, ntuples, GrB_SECOND_UINT64));
+     272          10 :     *result = T;
+     273          10 :     T = NULL ;
+     274             : 
+     275          10 :     LG_FREE_ALL;
+     276          10 :     return GrB_SUCCESS;
+     277             : #endif
+     278             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_scc.c.func-sort-c.html b/experimental/algorithm/LAGraph_scc.c.func-sort-c.html new file mode 100644 index 0000000000..9ccf8b0df9 --- /dev/null +++ b/experimental/algorithm/LAGraph_scc.c.func-sort-c.html @@ -0,0 +1,88 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_scc.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_scc.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:103103100.0 %
Date:2024-08-29 20:08:04Functions:44100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_scc53
propagate160
trim_one127480
edge_removal1515400
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_scc.c.func.html b/experimental/algorithm/LAGraph_scc.c.func.html new file mode 100644 index 0000000000..1ab72bd0a9 --- /dev/null +++ b/experimental/algorithm/LAGraph_scc.c.func.html @@ -0,0 +1,88 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_scc.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_scc.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:103103100.0 %
Date:2024-08-29 20:08:04Functions:44100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_scc53
edge_removal1515400
propagate160
trim_one127480
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LAGraph_scc.c.gcov.html b/experimental/algorithm/LAGraph_scc.c.gcov.html new file mode 100644 index 0000000000..11b2028724 --- /dev/null +++ b/experimental/algorithm/LAGraph_scc.c.gcov.html @@ -0,0 +1,321 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LAGraph_scc.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LAGraph_scc.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:103103100.0 %
Date:2024-08-29 20:08:04Functions:44100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_scc.c
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Yongzhe Zhang (zyz915@gmail.com)
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : /**
+      19             :  * Code is based on the Min-Label algorithm described in the following paper:
+      20             :  * D. Yan, J. Cheng, K. Xin, Y. Lu, W. Ng, Y. Bu, "Pregel Algorithms for Graph
+      21             :  * Connectivity Problems with Performance Guarantees"
+      22             :  * Proc. VLDB Endow. 7, 14 (October 2014), 1821–1832.
+      23             :  * DOI: https://doi.org/10.14778/2733085.2733089
+      24             :  **/
+      25             : 
+      26             : #define LG_FREE_ALL ;
+      27             : 
+      28             : #include "LG_internal.h"
+      29             : #include <LAGraph.h>
+      30             : #include <LAGraphX.h>
+      31             : 
+      32             : #if LAGRAPH_SUITESPARSE
+      33             : 
+      34             : //****************************************************************************
+      35             : // global C arrays used in SelectOp
+      36             : GrB_Index *I = NULL, *V = NULL, *F = NULL, *B = NULL, *M = NULL;
+      37             : 
+      38             : // edge_removal:
+      39             : //  - remove the edges connected to newly identified SCCs (vertices u with M[u]==1)
+      40             : //  - remove the edges (u, v) where u and v can never be in the same SCC.
+      41             : //
+      42             : // Here's a brief explanation of the second case. After the forward and backward
+      43             : // propagation, each vertex u has two labels
+      44             : //  - F[u]: the smallest vertex that can reach u
+      45             : //  - B[u]: the smallest vertex that is reachable from u
+      46             : // If two vertices u and v are in the same SCC, then F[u]==F[v] and B[u]==B[v] must
+      47             : // hold. The converse is not true unless F[u]==B[u]. However, we can safely remove
+      48             : // an edge (u, v) if either F[u]!=F[v] or B[u]!=B[v] holds, which can accelerate
+      49             : // the SCC computation in the future rounds.
+      50             : 
+      51             : void edge_removal (bool *z, const void *x, GrB_Index i, GrB_Index j, const void *thunk) ;
+      52     1515400 : void edge_removal (bool *z, const void *x, GrB_Index i, GrB_Index j, const void *thunk)
+      53             : {
+      54     1515400 :     (*z) = (!M[i] && !M[j] && F[i] == F[j] && B[i] == B[j]) ;
+      55     1515400 : }
+      56             : 
+      57             : //****************************************************************************
+      58             : // trim_one: remove the edges connected to trivial SCCs
+      59             : //  - A vertex is a trivial SCC if it has no incoming or outgoing edges.
+      60             : //  - M[i] = i   | if vertex i is a trivial SCC
+      61             : //    M[i] = n   | otherwise
+      62             : 
+      63             : void trim_one (bool *z, const void *x, GrB_Index i, GrB_Index j, const void *thunk) ;
+      64      127480 : void trim_one (bool *z, const void *x, GrB_Index i, GrB_Index j, const void *thunk)
+      65             : {
+      66      127480 :     (*z) = (M[i] == M[j]) ;
+      67      127480 : }
+      68             : 
+      69             : //****************************************************************************
+      70             : // label propagation
+      71             : //  - label  : (input/output) labels
+      72             : //  - mask   : (input) mask
+      73             : //  - A      : (input) original matrix
+      74             : //  - AT     : (input) transposed matrix
+      75             : //  - n      : (input) number of vertices
+      76             : 
+      77         160 : static GrB_Info propagate (GrB_Vector label, GrB_Vector mask,
+      78             :         GrB_Matrix A, GrB_Matrix AT, GrB_Index n, char *msg)
+      79             : {
+      80             :     GrB_Info info;
+      81             :     // semirings
+      82             : 
+      83             :     GrB_Vector s, t;
+      84         160 :     GRB_TRY (GrB_Vector_new (&s, GrB_UINT64, n));
+      85         160 :     GRB_TRY (GrB_Vector_new (&t, GrB_UINT64, n));
+      86         160 :     GRB_TRY (GrB_assign (s, mask, 0, label, GrB_ALL, 0, 0));
+      87         160 :     GRB_TRY (GrB_assign (t, 0, 0, label, GrB_ALL, 0, 0));
+      88             : 
+      89             :     GrB_Index active;
+      90             :     while (true)
+      91             :     {
+      92        7186 :         GRB_TRY (GrB_vxm (t, 0, GrB_MIN_UINT64,
+      93             :                                  GrB_MIN_FIRST_SEMIRING_UINT64, s, A, 0));
+      94        7186 :         GRB_TRY (GrB_eWiseMult (mask, 0, 0, GxB_ISNE_UINT64, t, label, 0));
+      95        7186 :         GRB_TRY (GrB_assign (label, mask, 0, t, GrB_ALL, 0, 0));
+      96        7186 :         GRB_TRY (GrB_reduce (&active, 0, GrB_PLUS_MONOID_UINT64, mask, 0));
+      97        7186 :         if (active == 0) break;
+      98        7026 :         GRB_TRY (GrB_Vector_clear (s));
+      99        7026 :         GRB_TRY (GrB_assign (s, mask, 0, label, GrB_ALL, 0, 0));
+     100             :     }
+     101             : 
+     102         160 :     GRB_TRY (GrB_free (&s));
+     103         160 :     GRB_TRY (GrB_free (&t));
+     104         160 :     return GrB_SUCCESS;
+     105             : }
+     106             : 
+     107             : #endif
+     108             : 
+     109             : //****************************************************************************
+     110             : //****************************************************************************
+     111          53 : int LAGraph_scc
+     112             : (
+     113             :     GrB_Vector *result,     // output: array of component identifiers
+     114             :     GrB_Matrix A,           // input matrix
+     115             :     char *msg
+     116             : )
+     117             : {
+     118             : 
+     119          53 :     LG_CLEAR_MSG ;
+     120             : #if !LAGRAPH_SUITESPARSE
+     121             :     LG_ASSERT (false, GrB_NOT_IMPLEMENTED) ;
+     122             : #else
+     123             :     GrB_Info info;
+     124             :     GrB_Vector scc;
+     125             :     GrB_Vector ind;
+     126             :     GrB_Vector inf;
+     127             :     GrB_Vector f, b, mask;
+     128          53 :     GrB_IndexUnaryOp sel1 = NULL, sel2 = NULL ;
+     129             :     GrB_Monoid Add;
+     130             : 
+     131          53 :     if (result == NULL || A == NULL) return (GrB_NULL_POINTER) ;
+     132             : 
+     133             :     GrB_Index n, ncols, nvals;
+     134          52 :     GRB_TRY (GrB_Matrix_nrows (&n, A));
+     135          52 :     GRB_TRY (GrB_Matrix_ncols (&ncols, A));
+     136          52 :     if (n != ncols) return (GrB_DIMENSION_MISMATCH) ;
+     137             : 
+     138             :     // store the graph in both directions (forward / backward)
+     139             :     GrB_Matrix FW, BW;
+     140          51 :     GRB_TRY (GrB_Matrix_new (&FW, GrB_BOOL, n, n));
+     141          51 :     GRB_TRY (GrB_Matrix_new (&BW, GrB_BOOL, n, n));
+     142          51 :     GRB_TRY (GrB_transpose (FW, 0, 0, A, GrB_DESC_T0)); // FW = A
+     143          51 :     GRB_TRY (GrB_transpose (BW, 0, 0, A, 0));     // BW = A'
+     144             : 
+     145             :     // check format
+     146             :     GxB_Format_Value A_format, AT_format;
+     147          51 :     GRB_TRY (GxB_get (FW, GxB_FORMAT, &A_format));
+     148          51 :     GRB_TRY (GxB_get (BW, GxB_FORMAT, &AT_format));
+     149             : 
+     150          51 :     bool is_csr = (A_format == GxB_BY_ROW && AT_format == GxB_BY_ROW);
+     151          51 :     if (!is_csr) return (GrB_INVALID_VALUE) ;
+     152             : 
+     153          51 :     I = (GrB_Index*) malloc(sizeof(GrB_Index) * n);
+     154          51 :     V = (GrB_Index*) malloc(sizeof(GrB_Index) * n);
+     155          51 :     F = (GrB_Index*) malloc(sizeof(GrB_Index) * n);
+     156          51 :     B = (GrB_Index*) malloc(sizeof(GrB_Index) * n);
+     157          51 :     M = (GrB_Index*) malloc(sizeof(GrB_Index) * n);
+     158       19605 :     for (GrB_Index i = 0; i < n; i++)
+     159       19554 :         I[i] = V[i] = i;
+     160             : 
+     161             :     // scc: the SCC identifier for each vertex
+     162             :     // scc[u] == n: not assigned yet
+     163          51 :     GRB_TRY (GrB_Vector_new (&scc, GrB_UINT64, n));
+     164             :     // vector of indices: ind[i] == i
+     165          51 :     GRB_TRY (GrB_Vector_new (&ind, GrB_UINT64, n));
+     166          51 :     GRB_TRY (GrB_Vector_build (ind, I, V, n, GrB_PLUS_UINT64));
+     167             :     // vector of infinite value: inf[i] == n
+     168          51 :     GRB_TRY (GrB_Vector_new (&inf, GrB_UINT64, n));
+     169          51 :     GRB_TRY (GrB_assign (inf, 0, 0, n, GrB_ALL, 0, 0));
+     170             :     // other vectors
+     171          51 :     GRB_TRY (GrB_Vector_new (&f, GrB_UINT64, n));
+     172          51 :     GRB_TRY (GrB_Vector_new (&b, GrB_UINT64, n));
+     173          51 :     GRB_TRY (GrB_Vector_new (&mask, GrB_UINT64, n));
+     174          51 :     GRB_TRY (GrB_IndexUnaryOp_new (&sel1, (void *) trim_one, GrB_BOOL, GrB_UINT64, GrB_UINT64));
+     175          51 :     GRB_TRY (GrB_IndexUnaryOp_new (&sel2, (void *) edge_removal, GrB_BOOL, GrB_UINT64, GrB_UINT64));
+     176             : 
+     177             :     // remove trivial SCCs
+     178          51 :     GRB_TRY (GrB_reduce (f, 0, GrB_PLUS_UINT64, GrB_PLUS_UINT64, FW, 0));
+     179          51 :     GRB_TRY (GrB_reduce (b, 0, GrB_PLUS_UINT64, GrB_PLUS_UINT64, BW, 0));
+     180          51 :     GRB_TRY (GrB_eWiseMult (mask, 0, GxB_LAND_UINT64, GxB_LAND_UINT64, f, b, 0));
+     181          51 :     GRB_TRY (GrB_Vector_nvals (&nvals, mask));
+     182             : 
+     183          51 :     GRB_TRY (GrB_assign (scc, 0, 0, ind, GrB_ALL, 0, 0));
+     184          51 :     GRB_TRY (GrB_assign (scc, mask, 0, n, GrB_ALL, 0, 0));
+     185          51 :     GRB_TRY (GrB_Vector_clear (mask));
+     186             : 
+     187          51 :     if (nvals < n)
+     188             :     {
+     189           9 :         GRB_TRY (GrB_Vector_extractTuples (I, M, &n, scc));
+     190           9 :         GRB_TRY (GrB_select (FW, 0, 0, sel1, FW, 0, 0));
+     191           9 :         GRB_TRY (GrB_select (BW, 0, 0, sel1, BW, 0, 0));
+     192             :     }
+     193             : 
+     194          51 :     GRB_TRY (GrB_Matrix_nvals (&nvals, FW));
+     195         131 :     while (nvals > 0)
+     196             :     {
+     197          80 :         GRB_TRY (GrB_eWiseMult (mask, 0, 0, GxB_ISEQ_UINT64, scc, inf, 0));
+     198          80 :         GRB_TRY (GrB_assign (f, 0, 0, ind, GrB_ALL, 0, 0));
+     199          80 :         LG_TRY (propagate (f, mask, FW, BW, n, msg));
+     200             : 
+     201          80 :         GRB_TRY (GrB_eWiseMult (mask, 0, 0, GxB_ISEQ_UINT64, f, ind, 0));
+     202          80 :         GRB_TRY (GrB_assign (b, 0, 0, inf, GrB_ALL, 0, 0));
+     203          80 :         GRB_TRY (GrB_assign (b, mask, 0, ind, GrB_ALL, 0, 0));
+     204          80 :         LG_TRY (propagate (b, mask, BW, FW, n, msg));
+     205             : 
+     206          80 :         GRB_TRY (GrB_eWiseMult (mask, 0, 0, GxB_ISEQ_UINT64, f, b, 0));
+     207          80 :         GRB_TRY (GrB_assign (scc, mask, GrB_MIN_UINT64, f, GrB_ALL, 0, 0));
+     208             : 
+     209          80 :         GRB_TRY (GrB_Vector_extractTuples (I, F, &n, f));
+     210          80 :         GRB_TRY (GrB_Vector_extractTuples (I, B, &n, b));
+     211          80 :         GRB_TRY (GrB_Vector_extractTuples (I, M, &n, mask));
+     212             : 
+     213          80 :         GRB_TRY (GrB_select (FW, 0, 0, sel2, FW, 0, 0));
+     214          80 :         GRB_TRY (GrB_select (BW, 0, 0, sel2, BW, 0, 0));
+     215             : 
+     216          80 :         GRB_TRY (GrB_Matrix_nvals (&nvals, FW));
+     217             :     }
+     218          51 :     GRB_TRY (GrB_eWiseMult (mask, 0, 0, GxB_ISEQ_UINT64, scc, inf, 0));
+     219          51 :     GRB_TRY (GrB_assign (scc, mask, 0, ind, GrB_ALL, 0, 0));
+     220             : 
+     221          51 :     GRB_TRY (GrB_eWiseMult (mask, 0, 0, GxB_ISEQ_UINT64, scc, ind, 0));
+     222          51 :     GRB_TRY (GrB_reduce (&nvals, 0, GrB_PLUS_MONOID_UINT64, mask, 0));
+     223             : 
+     224          51 :     *result = scc;
+     225          51 :     scc = NULL;
+     226             : 
+     227          51 :     free (I);
+     228          51 :     free (V);
+     229          51 :     free (F);
+     230          51 :     free (B);
+     231          51 :     free (M);
+     232          51 :     GrB_free (&ind);
+     233          51 :     GrB_free (&inf);
+     234          51 :     GrB_free (&f);
+     235          51 :     GrB_free (&b);
+     236          51 :     GrB_free (&mask);
+     237          51 :     GrB_free (&FW);
+     238          51 :     GrB_free (&BW);
+     239          51 :     GrB_free (&sel1);
+     240          51 :     GrB_free (&sel2);
+     241          51 :     GrB_free (&scc);
+     242             : 
+     243          51 :     return GrB_SUCCESS;
+     244             : #endif
+     245             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LG_CC_FastSV5.c.func-sort-c.html b/experimental/algorithm/LG_CC_FastSV5.c.func-sort-c.html new file mode 100644 index 0000000000..d3fa046e4f --- /dev/null +++ b/experimental/algorithm/LG_CC_FastSV5.c.func-sort-c.html @@ -0,0 +1,92 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LG_CC_FastSV5.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LG_CC_FastSV5.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:203203100.0 %
Date:2024-08-29 20:08:04Functions:55100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
ht_most_frequent4
LG_CC_FastSV524
ht_init48
ht_sample48
Reduce_assign3290
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LG_CC_FastSV5.c.func.html b/experimental/algorithm/LG_CC_FastSV5.c.func.html new file mode 100644 index 0000000000..8ddc22ea39 --- /dev/null +++ b/experimental/algorithm/LG_CC_FastSV5.c.func.html @@ -0,0 +1,92 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LG_CC_FastSV5.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LG_CC_FastSV5.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:203203100.0 %
Date:2024-08-29 20:08:04Functions:55100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_CC_FastSV524
Reduce_assign3290
ht_init48
ht_most_frequent4
ht_sample48
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/LG_CC_FastSV5.c.gcov.html b/experimental/algorithm/LG_CC_FastSV5.c.gcov.html new file mode 100644 index 0000000000..0a86a3e7cd --- /dev/null +++ b/experimental/algorithm/LG_CC_FastSV5.c.gcov.html @@ -0,0 +1,864 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm/LG_CC_FastSV5.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithm - LG_CC_FastSV5.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:203203100.0 %
Date:2024-08-29 20:08:04Functions:55100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LG_CC_FastSV5: connected components
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Yongzhe Zhang; modified by Tim Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // Code is based on the algorithm described in the following paper
+      19             : // Zhang, Azad, Hu. FastSV: FastSV: A Distributed-Memory Connected Component
+      20             : // Algorithm with Fast Convergence (SIAM PP20)
+      21             : 
+      22             : // A subsequent update to the algorithm is here (which might not be reflected
+      23             : // in this code):
+      24             : //
+      25             : // Yongzhe Zhang, Ariful Azad, Aydin Buluc: Parallel algorithms for finding
+      26             : // connected components using linear algebra. J. Parallel Distributed Comput.
+      27             : // 144: 14-27 (2020).
+      28             : 
+      29             : // Modified by Tim Davis, Texas A&M University
+      30             : 
+      31             : // The input matrix A must be symmetric.  Self-edges (diagonal entries) are
+      32             : // OK, and are ignored.  The values and type of A are ignored; just its
+      33             : // structure is accessed.
+      34             : 
+      35             : // The matrix A must have dimension 2^32 or less.
+      36             : // todo: Need a 64-bit version of this method.
+      37             : 
+      38             : // todo: this function is not thread-safe, since it exports G->A and then
+      39             : // reimports it back.  G->A is unchanged when the function returns, but during
+      40             : // execution G->A is invalid.
+      41             : 
+      42             : // A note about "todo" and "fixme" in this file:  these do not need to be fixed
+      43             : // or changed for this method, since the revised version appears as
+      44             : // src/algorithm/LG_CC_FastSV6.c.  They have thus been changed here to lower
+      45             : // case.
+      46             : 
+      47             : // todo: free all workspace in LG_FREE_ALL
+      48             : #define LG_FREE_ALL ;
+      49             : 
+      50             : #include "LG_internal.h"
+      51             : 
+      52             : #if LAGRAPH_SUITESPARSE
+      53             : 
+      54             : //------------------------------------------------------------------------------
+      55             : // hash functions: todo describe me
+      56             : //------------------------------------------------------------------------------
+      57             : 
+      58             : // hash table size must be a power of 2
+      59             : #define HASH_SIZE 1024
+      60             : 
+      61             : // number of samples to insert into the hash table
+      62             : // todo: this seems to be a lot of entries for a HASH_SIZE of 1024.
+      63             : // There could be lots of collisions.
+      64             : #define HASH_SAMPLES 864
+      65             : 
+      66             : #define HASH(x) (((x << 4) + x) & (HASH_SIZE-1))
+      67             : #define NEXT(x) ((x + 23) & (HASH_SIZE-1))
+      68             : 
+      69             : //------------------------------------------------------------------------------
+      70             : // ht_init: todo describe me
+      71             : //------------------------------------------------------------------------------
+      72             : 
+      73             : // Clear the hash table counts (ht_val [0:HASH_SIZE-1] = 0), and set all hash
+      74             : // table entries as empty (ht_key [0:HASH_SIZE-1] =-1).
+      75             : 
+      76             : // todo: the memset of ht_key is confusing
+      77             : 
+      78             : // todo: the name "ht_val" is confusing.  It is not a value, but a count of
+      79             : // the number of times the value x = ht_key [h] has been inserted into the
+      80             : // hth position in the hash table.  It should be renamed ht_cnt.
+      81             : 
+      82          48 : static inline void ht_init
+      83             : (
+      84             :     int32_t *ht_key,
+      85             :     int32_t *ht_val
+      86             : )
+      87             : {
+      88          48 :     memset (ht_key, -1, sizeof (int32_t) * HASH_SIZE) ;
+      89          48 :     memset (ht_val,  0, sizeof (int32_t) * HASH_SIZE) ;
+      90          48 : }
+      91             : 
+      92             : //------------------------------------------------------------------------------
+      93             : // ht_sample: todo describe me
+      94             : //------------------------------------------------------------------------------
+      95             : 
+      96             : //
+      97             : 
+      98          48 : static inline void ht_sample
+      99             : (
+     100             :     uint32_t *V32,      // array of size n (todo: this is a bad variable name)
+     101             :     int32_t n,
+     102             :     int32_t samples,    // number of samples to take from V32
+     103             :     int32_t *ht_key,
+     104             :     int32_t *ht_val,
+     105             :     uint64_t *seed
+     106             : )
+     107             : {
+     108       41520 :     for (int32_t k = 0 ; k < samples ; k++)
+     109             :     {
+     110             :         // select an entry from V32 at random
+     111       41472 :         int32_t x = V32 [LG_Random60 (seed) % n] ;
+     112             : 
+     113             :         // find x in the hash table
+     114             :         // todo: make this loop a static inline function (see also below)
+     115       41472 :         int32_t h = HASH (x) ;
+     116       46722 :         while (ht_key [h] != -1 && ht_key [h] != x)
+     117             :         {
+     118        5250 :             h = NEXT (h) ;
+     119             :         }
+     120             : 
+     121       41472 :         ht_key [h] = x ;
+     122       41472 :         ht_val [h]++ ;
+     123             :     }
+     124          48 : }
+     125             : 
+     126             : //------------------------------------------------------------------------------
+     127             : // ht_most_frequent: todo describe me
+     128             : //------------------------------------------------------------------------------
+     129             : 
+     130             : // todo what if key is returned as -1?  Code breaks.  todo: handle this case
+     131             : 
+     132           4 : static inline int32_t ht_most_frequent
+     133             : (
+     134             :     int32_t *ht_key,
+     135             :     int32_t *ht_val
+     136             : )
+     137             : {
+     138           4 :     int32_t key = -1 ;
+     139           4 :     int32_t val = 0 ;                       // max (ht_val [0:HASH_SIZE-1])
+     140        4100 :     for (int32_t h = 0 ; h < HASH_SIZE ; h++)
+     141             :     {
+     142        4096 :         if (ht_val [h] > val)
+     143             :         {
+     144          10 :             key = ht_key [h] ;
+     145          10 :             val = ht_val [h] ;
+     146             :         }
+     147             :     }
+     148           4 :     return (key) ;      // return most frequent key
+     149             : }
+     150             : 
+     151             : //------------------------------------------------------------------------------
+     152             : // Reduce_assign32:  w (index) += s, using MIN as the "+=" accum operator
+     153             : //------------------------------------------------------------------------------
+     154             : 
+     155             : // mask = NULL, accumulator = GrB_MIN_UINT32, descriptor = NULL.
+     156             : // Duplicates are summed with the accumulator, which differs from how
+     157             : // GrB_assign works.  GrB_assign states that the presence of duplicates results
+     158             : // in undefined behavior.  GrB_assign in SuiteSparse:GraphBLAS follows the
+     159             : // MATLAB rule, which discards all but the first of the duplicates.
+     160             : 
+     161             : // todo: add this to GraphBLAS as a variant of GrB_assign, either as
+     162             : // GxB_assign_accum (or another name), or as a GxB_* descriptor setting.
+     163             : 
+     164          90 : static inline int Reduce_assign32
+     165             : (
+     166             :     GrB_Vector *w_handle,   // vector of size n, all entries present
+     167             :     GrB_Vector *s_handle,   // vector of size n, all entries present
+     168             :     uint32_t *index,        // array of size n, can have duplicates
+     169             :     GrB_Index n,
+     170             :     int nthreads,
+     171             :     int32_t *ht_key,        // hash table
+     172             :     int32_t *ht_val,        // hash table (count of # of entries)
+     173             :     uint64_t *seed,         // random
+     174             :     char *msg
+     175             : )
+     176             : {
+     177             : 
+     178             :     GrB_Type w_type, s_type ;
+     179             :     GrB_Index w_n, s_n, w_nvals, s_nvals, *w_i, *s_i, w_size, s_size ;
+     180             :     uint32_t *w_x, *s_x ;
+     181          90 :     bool s_iso = false ;
+     182             : 
+     183             :     //--------------------------------------------------------------------------
+     184             :     // export w and s
+     185             :     //--------------------------------------------------------------------------
+     186             : 
+     187             :     // export the GrB_Vectors w and s as full arrays, to get direct access to
+     188             :     // their contents.  Note that this would fail if w or s are not full, with
+     189             :     // all entries present.
+     190          90 :     GRB_TRY (GxB_Vector_export_Full (w_handle, &w_type, &w_n, (void **) &w_x,
+     191             :         &w_size, NULL, NULL)) ;
+     192          90 :     GRB_TRY (GxB_Vector_export_Full (s_handle, &s_type, &s_n, (void **) &s_x,
+     193             :         &s_size, &s_iso, NULL)) ;
+     194             : 
+     195             :     #if defined ( COVERAGE )
+     196          90 :     if (n >= 200)   // for test coverage only; do not use in production!!
+     197             :     #else
+     198             :     if (nthreads >= 4)
+     199             :     #endif
+     200             :     {
+     201             : 
+     202             :         // allocate a buf array for each thread, of size HASH_SIZE
+     203             :         uint32_t *mem ;
+     204          44 :         LAGRAPH_TRY (LAGraph_Malloc ((void **) &mem, nthreads*HASH_SIZE,
+     205             :             sizeof (uint32_t), msg)) ;
+     206             :         // todo: check out-of-memory condition here
+     207             : 
+     208             :         // todo why is hashing needed here?  hashing is slow for what needs
+     209             :         // to be computed here.  GraphBLAS has fast MIN atomic monoids that
+     210             :         // do not require hashing.
+     211          44 :         ht_init (ht_key, ht_val) ;
+     212          44 :         ht_sample (index, n, HASH_SAMPLES, ht_key, ht_val, seed) ;
+     213             : 
+     214             :         int tid;
+     215             :         #pragma omp parallel for num_threads(nthreads) schedule(static)
+     216          88 :         for (tid = 0 ; tid < nthreads ; tid++)
+     217             :         {
+     218             :             // get the thread-specific buf array of size HASH_SIZE
+     219             :             // todo: buf is a bad variable name; it's not a "buffer",
+     220             :             // but a local workspace to compute the local version of w_x.
+     221          44 :             uint32_t *buf = mem + tid * HASH_SIZE ;
+     222             : 
+     223             :             // copy the values from the global hash table into buf
+     224       45100 :             for (int32_t h = 0 ; h < HASH_SIZE ; h++)
+     225             :             {
+     226       45056 :                 if (ht_key [h] != -1)
+     227             :                 {
+     228       15386 :                     buf [h] = w_x [ht_key [h]] ;
+     229             :                 }
+     230             :             }
+     231             : 
+     232             :             // this thread works on index [kstart:kend]
+     233          44 :             int32_t kstart = (n * tid + nthreads - 1) / nthreads ;
+     234          44 :             int32_t kend = (n * tid + n + nthreads - 1) / nthreads ;
+     235       89968 :             for (int32_t k = kstart ; k < kend ; k++)
+     236             :             {
+     237       89924 :                 uint32_t i = index [k] ;
+     238             : 
+     239             :                 // todo: make this loop a static inline function
+     240       89924 :                 int32_t h = HASH (i) ;
+     241      126336 :                 while (ht_key [h] != -1 && ht_key [h] != i)
+     242             :                 {
+     243       36412 :                     h = NEXT (h) ;
+     244             :                 }
+     245             : 
+     246       89924 :                 if (ht_key [h] == -1)
+     247             :                 {
+     248             :                     // todo is this a race condition?
+     249       27790 :                     w_x [i] = LAGRAPH_MIN (w_x [i], s_x [s_iso?0:k]) ;
+     250             :                 }
+     251             :                 else
+     252             :                 {
+     253       62134 :                     buf [h] = LAGRAPH_MIN (buf [h], s_x [s_iso?0:k]) ;
+     254             :                 }
+     255             :             }
+     256             :         }
+     257             : 
+     258             :         // combine intermediate results from each thread
+     259       45100 :         for (int32_t h = 0 ; h < HASH_SIZE ; h++)
+     260             :         {
+     261       45056 :             int32_t i = ht_key [h] ;
+     262       45056 :             if (i != -1)
+     263             :             {
+     264       30772 :                 for (tid = 0 ; tid < nthreads ; tid++)
+     265             :                 {
+     266       15386 :                     w_x [i] = LAGRAPH_MIN (w_x [i], mem [tid * HASH_SIZE + h]) ;
+     267             :                 }
+     268             :             }
+     269             :         }
+     270             : 
+     271          44 :         LAGraph_Free ((void **) &mem, NULL) ;
+     272             :     }
+     273             :     else
+     274             :     {
+     275             :         // sequential version
+     276         728 :         for (GrB_Index k = 0 ; k < n ; k++)
+     277             :         {
+     278         682 :             uint32_t i = index [k] ;
+     279         682 :             w_x [i] = LAGRAPH_MIN (w_x [i], s_x [s_iso?0:k]) ;
+     280             :         }
+     281             :     }
+     282             : 
+     283             :     //--------------------------------------------------------------------------
+     284             :     // reimport w and s back into GrB_Vectors, and return result
+     285             :     //--------------------------------------------------------------------------
+     286             : 
+     287             :     // s is unchanged.  It was exported only to compute w (index) += s
+     288             : 
+     289          90 :     GRB_TRY (GxB_Vector_import_Full (w_handle, w_type, w_n, (void **) &w_x,
+     290             :         w_size, false, NULL)) ;
+     291          90 :     GRB_TRY (GxB_Vector_import_Full (s_handle, s_type, s_n, (void **) &s_x,
+     292             :         s_size, s_iso, NULL)) ;
+     293             : 
+     294          90 :     return (GrB_SUCCESS) ;
+     295             : }
+     296             : 
+     297             : //------------------------------------------------------------------------------
+     298             : // LG_CC_FastSV5
+     299             : //------------------------------------------------------------------------------
+     300             : 
+     301             : // The output of LG_CC_FastSV5 is a vector component, where
+     302             : // component(i)=s if node i is in the connected compononent whose
+     303             : // representative node is node s.  If s is a representative, then
+     304             : // component(s)=s.  The number of connected components in the graph G is the
+     305             : // number of representatives.
+     306             : 
+     307             : #undef  LG_FREE_ALL
+     308             : #define LG_FREE_ALL                             \
+     309             : {                                               \
+     310             :     LAGraph_Free ((void **) &I, NULL) ;         \
+     311             :     LAGraph_Free ((void **) &V32, NULL) ;       \
+     312             :     LAGraph_Free ((void **) &ht_key, NULL) ;    \
+     313             :     LAGraph_Free ((void **) &ht_val, NULL) ;    \
+     314             :     /* todo why is T not freed?? */             \
+     315             :     GrB_free (&f) ;                             \
+     316             :     GrB_free (&gp) ;                            \
+     317             :     GrB_free (&mngp) ;                          \
+     318             :     GrB_free (&gp_new) ;                        \
+     319             :     GrB_free (&mod) ;                           \
+     320             : }
+     321             : 
+     322             : #endif
+     323             : 
+     324          24 : int LG_CC_FastSV5           // SuiteSparse:GraphBLAS method, with GxB extensions
+     325             : (
+     326             :     // output
+     327             :     GrB_Vector *component,  // component(i)=s if node is in the component s
+     328             :     // inputs
+     329             :     LAGraph_Graph G,        // input graph, G->A can change
+     330             :     char *msg
+     331             : )
+     332             : {
+     333             : 
+     334             :     //--------------------------------------------------------------------------
+     335             :     // check inputs
+     336             :     //--------------------------------------------------------------------------
+     337             : 
+     338          24 :     LG_CLEAR_MSG ;
+     339             : 
+     340             : #if !LAGRAPH_SUITESPARSE
+     341             :     LG_ASSERT_MSG (false, GrB_NOT_IMPLEMENTED, "SuiteSparse required") ;
+     342             : #else
+     343             : 
+     344          24 :     uint32_t *V32 = NULL ;
+     345          24 :     int32_t *ht_key = NULL, *ht_val = NULL ;
+     346          24 :     GrB_Index n, nnz, *I = NULL ;
+     347          24 :     GrB_Vector f = NULL, gp_new = NULL, mngp = NULL, mod = NULL, gp = NULL ;
+     348          24 :     GrB_Matrix T = NULL ;
+     349             : 
+     350          24 :     LG_TRY (LAGraph_CheckGraph (G, msg)) ;
+     351          24 :     LG_ASSERT (component != NULL, GrB_NULL_POINTER) ;
+     352             : 
+     353          24 :     LG_ASSERT_MSG ((G->kind == LAGraph_ADJACENCY_UNDIRECTED ||
+     354             :        (G->kind == LAGraph_ADJACENCY_DIRECTED &&
+     355             :         G->is_symmetric_structure == LAGraph_TRUE)),
+     356             :         -1001, "G->A must be known to be symmetric") ;
+     357             : 
+     358          24 :     GrB_Matrix S = G->A ;
+     359          24 :     GRB_TRY (GrB_Matrix_nrows (&n, S)) ;
+     360          24 :     GRB_TRY (GrB_Matrix_nvals (&nnz, S)) ;
+     361             : 
+     362          24 :     LG_ASSERT_MSG (n <= UINT32_MAX, -1, "problem too large (fixme)") ;
+     363             : 
+     364             :     #define FASTSV_SAMPLES 4
+     365             : 
+     366          24 :     bool sampling = (n * FASTSV_SAMPLES * 2 < nnz) ;
+     367             : 
+     368             :     // random number seed
+     369          24 :     uint64_t seed = n ;
+     370             : 
+     371             :     //--------------------------------------------------------------------------
+     372             :     // initializations
+     373             :     //--------------------------------------------------------------------------
+     374             : 
+     375             :     // determine # of threads to use for Reduce_assign
+     376             :     int nthreads, nthreads_outer, nthreads_inner ;
+     377          24 :     LG_TRY (LAGraph_GetNumThreads (&nthreads_outer, &nthreads_inner, msg)) ;
+     378          24 :     nthreads = nthreads_outer * nthreads_inner ;
+     379             : 
+     380          24 :     nthreads = LAGRAPH_MIN (nthreads, n / 16) ;
+     381          24 :     nthreads = LAGRAPH_MAX (nthreads, 1) ;
+     382             : 
+     383             :     // # of threads to use for typecast
+     384          24 :     int nthreads2 = n / (64*1024) ;
+     385          24 :     nthreads2 = LAGRAPH_MIN (nthreads2, nthreads) ;
+     386          24 :     nthreads2 = LAGRAPH_MAX (nthreads2, 1) ;
+     387             : 
+     388             :     // vectors
+     389          24 :     GRB_TRY (GrB_Vector_new (&f,      GrB_UINT32, n)) ;
+     390          24 :     GRB_TRY (GrB_Vector_new (&gp_new, GrB_UINT32, n)) ;
+     391          24 :     GRB_TRY (GrB_Vector_new (&mod,    GrB_BOOL,   n)) ;
+     392             : 
+     393             :     // temporary arrays
+     394          24 :     LAGRAPH_TRY (LAGraph_Malloc ((void **) &I  , n, sizeof (GrB_Index), msg)) ;
+     395          24 :     LAGRAPH_TRY (LAGraph_Malloc ((void **) &V32, n, sizeof (uint32_t), msg)) ;
+     396             : 
+     397             :     // prepare vectors
+     398             :     int64_t i;
+     399             :     #pragma omp parallel for num_threads(nthreads2) schedule(static)
+     400       16284 :     for (i = 0 ; i < n ; i++)
+     401             :     {
+     402       16260 :         I [i] = i ;
+     403       16260 :         V32 [i] = (uint32_t) i ;
+     404             :     }
+     405             : 
+     406          24 :     GRB_TRY (GrB_Vector_build (f, I, V32, n, GrB_PLUS_UINT32)) ;
+     407          24 :     GRB_TRY (GrB_Vector_dup (&gp,   f)) ;
+     408          24 :     GRB_TRY (GrB_Vector_dup (&mngp, f)) ;
+     409             : 
+     410             :     // allocate the hash table
+     411          24 :     LAGRAPH_TRY (LAGraph_Malloc ((void **) &ht_key, HASH_SIZE, sizeof (int32_t),
+     412             :         msg)) ;
+     413          24 :     LAGRAPH_TRY (LAGraph_Malloc ((void **) &ht_val, HASH_SIZE, sizeof (int32_t),
+     414             :         msg)) ;
+     415             : 
+     416             :     //--------------------------------------------------------------------------
+     417             :     // sample phase
+     418             :     //--------------------------------------------------------------------------
+     419             : 
+     420          24 :     if (sampling)
+     421             :     {
+     422             : 
+     423             :         //----------------------------------------------------------------------
+     424             :         // export S = G->A in CSR format
+     425             :         //----------------------------------------------------------------------
+     426             : 
+     427             :         // S is not modified.  It is only exported so that its contents can be
+     428             :         // read by the parallel loops below.
+     429             : 
+     430             :         GrB_Type type ;
+     431             :         GrB_Index nrows, ncols, nvals ;
+     432             :         size_t typesize ;
+     433             :         int64_t nonempty ;
+     434             :         GrB_Index *Sp, *Sj ;
+     435             :         void *Sx ;
+     436           4 :         bool S_jumbled = false ;
+     437             :         GrB_Index Sp_size, Sj_size, Sx_size ;
+     438           4 :         bool S_iso = false ;
+     439             : 
+     440           4 :         GRB_TRY (GrB_Matrix_nvals (&nvals, S)) ;
+     441           4 :         GRB_TRY (GxB_Matrix_export_CSR (&S, &type, &nrows, &ncols, &Sp, &Sj,
+     442             :             &Sx, &Sp_size, &Sj_size, &Sx_size,
+     443             :             &S_iso, &S_jumbled, NULL)) ;
+     444           4 :         GRB_TRY (GxB_Type_size (&typesize, type)) ;
+     445           4 :         G->A = NULL ;
+     446             : 
+     447             :         //----------------------------------------------------------------------
+     448             :         // allocate space to construct T
+     449             :         //----------------------------------------------------------------------
+     450             : 
+     451           4 :         GrB_Index Tp_len = nrows+1, Tp_size = Tp_len*sizeof(GrB_Index);
+     452           4 :         GrB_Index Tj_len = nvals,   Tj_size = Tj_len*sizeof(GrB_Index);
+     453           4 :         GrB_Index Tx_len = nvals ;
+     454             : 
+     455           4 :         GrB_Index *Tp = NULL, *Tj = NULL ;
+     456           4 :         GrB_Index Tx_size = typesize ;
+     457           4 :         void *Tx = NULL ;
+     458           4 :         int32_t *range = NULL ;
+     459           4 :         GrB_Index *count = NULL ;
+     460             : 
+     461           4 :         LAGRAPH_TRY (LAGraph_Malloc ((void **) &Tp, Tp_len,
+     462             :             sizeof (GrB_Index), msg)) ;
+     463           4 :         LAGRAPH_TRY (LAGraph_Malloc ((void **) &Tj, Tj_len,
+     464             :             sizeof (GrB_Index), msg)) ;
+     465           4 :         LAGRAPH_TRY (LAGraph_Calloc (&Tx, 1, typesize, msg)) ;   // T is iso
+     466             : 
+     467             :         //----------------------------------------------------------------------
+     468             :         // allocate workspace
+     469             :         //----------------------------------------------------------------------
+     470             : 
+     471           4 :         LAGRAPH_TRY (LAGraph_Malloc ((void **) &range, nthreads + 1,
+     472             :             sizeof (int32_t), msg)) ;
+     473           4 :         LAGRAPH_TRY (LAGraph_Malloc ((void **) &count, nthreads + 1,
+     474             :             sizeof (GrB_Index), msg)) ;
+     475             : 
+     476           4 :         memset (count, 0, sizeof (GrB_Index) * (nthreads + 1)) ;
+     477             : 
+     478             :         //----------------------------------------------------------------------
+     479             :         // define parallel tasks to construct T
+     480             :         //----------------------------------------------------------------------
+     481             : 
+     482             :         // thread tid works on rows range[tid]:range[tid+1]-1 of S and T
+     483          12 :         for (int tid = 0 ; tid <= nthreads ; tid++)
+     484             :         {
+     485           8 :             range [tid] = (n * tid + nthreads - 1) / nthreads ;
+     486             :         }
+     487             : 
+     488             :         //----------------------------------------------------------------------
+     489             :         // determine the number entries to be constructed in T for each thread
+     490             :         //----------------------------------------------------------------------
+     491             : 
+     492             :         int tid;
+     493             :         #pragma omp parallel for num_threads(nthreads) schedule(static)
+     494           8 :         for (tid = 0 ; tid < nthreads ; tid++)
+     495             :         {
+     496        9756 :             for (int32_t i = range [tid] ; i < range [tid+1] ; i++)
+     497             :             {
+     498        9752 :                 int32_t deg = Sp [i + 1] - Sp [i] ;
+     499        9752 :                 count [tid + 1] += LAGRAPH_MIN (FASTSV_SAMPLES, deg) ;
+     500             :             }
+     501             :         }
+     502             : 
+     503             :         //----------------------------------------------------------------------
+     504             :         // count = cumsum (count)
+     505             :         //----------------------------------------------------------------------
+     506             : 
+     507           8 :         for (tid = 0 ; tid < nthreads ; tid++)
+     508             :         {
+     509           4 :             count [tid + 1] += count [tid] ;
+     510             :         }
+     511             : 
+     512             :         //----------------------------------------------------------------------
+     513             :         // construct T
+     514             :         //----------------------------------------------------------------------
+     515             : 
+     516             :         // T (i,:) consists of the first FASTSV_SAMPLES of S (i,:).
+     517             : 
+     518             :         // todo: this could be done by GxB_Select, using a new operator.  Need
+     519             :         // to define a set of GxB_SelectOp operators that would allow for this.
+     520             : 
+     521             :         // Note that Tx is not modified.  Only Tp and Tj are constructed.
+     522             : 
+     523             :         #pragma omp parallel for num_threads(nthreads) schedule(static)
+     524           8 :         for (tid = 0 ; tid < nthreads ; tid++)
+     525             :         {
+     526           4 :             GrB_Index p = count [tid] ;
+     527           4 :             Tp [range [tid]] = p ;
+     528        9756 :             for (int32_t i = range [tid] ; i < range [tid+1] ; i++)
+     529             :             {
+     530             :                 // construct T (i,:) from the first entries in S (i,:)
+     531        9752 :                 for (int32_t j = 0 ;
+     532       40390 :                     j < FASTSV_SAMPLES && Sp [i] + j < Sp [i + 1] ; j++)
+     533             :                 {
+     534       30638 :                     Tj [p++] = Sj [Sp [i] + j] ;
+     535             :                 }
+     536        9752 :                 Tp [i + 1] = p ;
+     537             :             }
+     538             :         }
+     539             : 
+     540             :         //----------------------------------------------------------------------
+     541             :         // import the result into the GrB_Matrix T
+     542             :         //----------------------------------------------------------------------
+     543             : 
+     544             :         // Note that Tx is unmodified.
+     545             : 
+     546             :         // in SuiteSparse:GraphBLAS v5, sizes are in bytes, not entries
+     547           4 :         GrB_Index Tp_siz = Tp_size ;
+     548           4 :         GrB_Index Tj_siz = Tj_size ;
+     549           4 :         GrB_Index Tx_siz = Tx_size ;
+     550             : 
+     551           4 :         GrB_Index t_nvals = Tp [nrows] ;
+     552           4 :         GRB_TRY (GxB_Matrix_import_CSR (&T, type, nrows, ncols,
+     553             :                 &Tp, &Tj, &Tx, Tp_siz, Tj_siz, Tx_siz,
+     554             :                 true,   // T is iso
+     555             :                 S_jumbled, NULL)) ;
+     556             : 
+     557             :         //----------------------------------------------------------------------
+     558             :         // find the connected components of T
+     559             :         //----------------------------------------------------------------------
+     560             : 
+     561             :         // todo: this is nearly identical to the final phase below.
+     562             :         // Make this a function
+     563             : 
+     564           4 :         bool change = true, is_first = true ;
+     565          26 :         while (change)
+     566             :         {
+     567             :             // hooking & shortcutting
+     568          22 :             GRB_TRY (GrB_mxv (mngp, NULL, GrB_MIN_UINT32,
+     569             :                 GrB_MIN_SECOND_SEMIRING_UINT32, T, gp, NULL)) ;
+     570          22 :             if (!is_first)
+     571             :             {
+     572          18 :                 LG_TRY (Reduce_assign32 (&f, &mngp, V32, n, nthreads,
+     573             :                     ht_key, ht_val, &seed, msg)) ;
+     574             :             }
+     575          22 :             GRB_TRY (GrB_eWiseAdd (f, NULL, GrB_MIN_UINT32, GrB_MIN_UINT32,
+     576             :                 mngp, gp, NULL)) ;
+     577             : 
+     578             :             // calculate grandparent
+     579             :             // fixme: NULL parameter is SS:GrB extension
+     580          22 :             GRB_TRY (GrB_Vector_extractTuples (NULL, V32, &n, f)) ; // fixme
+     581             :             int32_t i;
+     582             :             #pragma omp parallel for num_threads(nthreads2) schedule(static)
+     583       54528 :             for (i = 0 ; i < n ; i++)
+     584             :             {
+     585       54506 :                 I [i] = (GrB_Index) V32 [i] ;
+     586             :             }
+     587          22 :             GRB_TRY (GrB_extract (gp_new, NULL, NULL, f, I, n, NULL)) ;
+     588             : 
+     589             :             // todo: GrB_Vector_extract should have a variant where the index
+     590             :             // list is not given by an array I, but as a GrB_Vector of type
+     591             :             // GrB_UINT64 (or which can be typecast to GrB_UINT64).  This is a
+     592             :             // common issue that arises in other algorithms as well.
+     593             :             // Likewise GrB_Matrix_extract, and all forms of GrB_assign.
+     594             : 
+     595             :             // check termination
+     596          22 :             GRB_TRY (GrB_eWiseMult (mod, NULL, NULL, GrB_NE_UINT32, gp_new,
+     597             :                 gp, NULL)) ;
+     598          22 :             GRB_TRY (GrB_reduce (&change, NULL, GrB_LOR_MONOID_BOOL, mod,
+     599             :                 NULL)) ;
+     600             : 
+     601             :             // swap gp and gp_new
+     602          22 :             GrB_Vector t = gp ; gp = gp_new ; gp_new = t ;
+     603          22 :             is_first = false ;
+     604             :         }
+     605             : 
+     606             :         //----------------------------------------------------------------------
+     607             :         // todo: describe me
+     608             :         //----------------------------------------------------------------------
+     609             : 
+     610           4 :         ht_init (ht_key, ht_val) ;
+     611           4 :         ht_sample (V32, n, HASH_SAMPLES, ht_key, ht_val, &seed) ;
+     612           4 :         int32_t key = ht_most_frequent (ht_key, ht_val) ;
+     613             :         // todo: what if key is returned as -1?  Then T below is invalid.
+     614             : 
+     615           4 :         int64_t t_nonempty = -1 ;
+     616           4 :         bool T_jumbled = false, T_iso = true ;
+     617             : 
+     618             :         // export T
+     619           4 :         GRB_TRY (GxB_Matrix_export_CSR (&T, &type, &nrows, &ncols, &Tp, &Tj,
+     620             :             &Tx, &Tp_siz, &Tj_siz, &Tx_siz,
+     621             :             &T_iso, &T_jumbled, NULL)) ;
+     622             : 
+     623             :         // todo what is this phase doing?  It is constructing a matrix T that
+     624             :         // depends only on S, key, and V32.  T contains a subset of the entries
+     625             :         // in S, except that T (i,:) is empty if
+     626             : 
+     627             :         // The prior content of T is ignored; it is exported from the earlier
+     628             :         // phase, only to reuse the allocated space for T.  However, T_jumbled
+     629             :         // is preserved from the prior matrix T, which doesn't make sense.
+     630             : 
+     631             :         // This parallel loop is badly load balanced.  Each thread operates on
+     632             :         // the same number of rows of S, regardless of how many entries appear
+     633             :         // in each set of rows.  It uses one thread per task, statically
+     634             :         // scheduled.
+     635             : 
+     636             :         #pragma omp parallel for num_threads(nthreads) schedule(static)
+     637           8 :         for (tid = 0 ; tid < nthreads ; tid++)
+     638             :         {
+     639           4 :             GrB_Index ptr = Sp [range [tid]] ;
+     640             :             // thread tid scans S (range [tid]:range [tid+1]-1,:),
+     641             :             // and constructs T(i,:) for all rows in this range.
+     642        9756 :             for (int32_t i = range [tid] ; i < range [tid+1] ; i++)
+     643             :             {
+     644        9752 :                 int32_t pv = V32 [i] ;  // what is pv?
+     645        9752 :                 Tp [i] = ptr ;          // start the construction of T(i,:)
+     646             :                 // T(i,:) is empty if pv == key
+     647        9752 :                 if (pv != key)
+     648             :                 {
+     649             :                     // scan S(i,:)
+     650       46550 :                     for (GrB_Index p = Sp [i] ; p < Sp [i+1] ; p++)
+     651             :                     {
+     652             :                         // get S(i,j)
+     653       41274 :                         int32_t j = Sj [p] ;
+     654       41274 :                         if (V32 [j] != key)
+     655             :                         {
+     656             :                             // add the entry T(i,j) to T, but skip it if
+     657             :                             // V32 [j] is equal to key
+     658       41264 :                             Tj [ptr++] = j ;
+     659             :                         }
+     660             :                     }
+     661             :                     // add the entry T(i,key) if there is room for it in T(i,:)
+     662        5276 :                     if (ptr - Tp [i] < Sp [i+1] - Sp [i])
+     663             :                     {
+     664           2 :                         Tj [ptr++] = key ;
+     665             :                     }
+     666             :                 }
+     667             :             }
+     668             :             // count the number of entries inserted into T by this thread?
+     669           4 :             count [tid] = ptr - Tp [range [tid]] ;
+     670             :         }
+     671             : 
+     672             :         // Compact empty space out of Tj not filled in from the above phase.
+     673             :         // This is a lot of work and should be done in parallel.
+     674           4 :         GrB_Index offset = 0 ;
+     675           8 :         for (tid = 0 ; tid < nthreads ; tid++)
+     676             :         {
+     677             : 
+     678             : //          this memcpy is not safe (src/dest can overlap)
+     679             : //          memcpy (Tj + offset, Tj + Tp [range [tid]],
+     680             : //              sizeof (GrB_Index) * count [tid]) ;
+     681             : 
+     682             : //          // using a for loop instead:
+     683             : //          GrB_Index *Tj_dest = Tj + offset ;
+     684             : //          GrB_Index *Tj_src  = Tj + Tp [range [tid]] ;
+     685             : //          for (int64_t k = 0 ; k < count [tid] ; k++)
+     686             : //          {
+     687             : //              Tj_dest [k] = Tj_src [k] ;
+     688             : //          }
+     689             : 
+     690             : //          this is safe (memmove_s not necessary):
+     691           4 :             memmove (Tj + offset, Tj + Tp [range [tid]],
+     692           4 :                 sizeof (GrB_Index) * count [tid]) ;
+     693             : 
+     694           4 :             offset += count [tid] ;
+     695           4 :             count [tid] = offset - count [tid] ;
+     696             :         }
+     697             : 
+     698             :         // Compact empty space out of Tp
+     699             :         #pragma omp parallel for num_threads(nthreads) schedule(static)
+     700           8 :         for (tid = 0 ; tid < nthreads ; tid++)
+     701             :         {
+     702           4 :             GrB_Index ptr = Tp [range [tid]] ;
+     703        9756 :             for (int32_t i = range [tid] ; i < range [tid+1] ; i++)
+     704             :             {
+     705        9752 :                 Tp [i] -= ptr - count [tid] ;
+     706             :             }
+     707             :         }
+     708             : 
+     709             :         // finalize T
+     710           4 :         Tp [n] = offset ;
+     711             : 
+     712             :         // free workspace
+     713           4 :         LAGraph_Free ((void **) &count, NULL) ;
+     714           4 :         LAGraph_Free ((void **) &range, NULL) ;
+     715             : 
+     716             :         // import S (unchanged since last export)
+     717           4 :         GRB_TRY (GxB_Matrix_import_CSR (&S, type, nrows, ncols,
+     718             :                 &Sp, &Sj, &Sx, Sp_size, Sj_size, Sx_size,
+     719             :                 S_iso, S_jumbled, NULL)) ;
+     720             : 
+     721             :         // import T for the final phase
+     722           4 :         GRB_TRY (GxB_Matrix_import_CSR (&T, type, nrows, ncols,
+     723             :                 &Tp, &Tj, &Tx, Tp_siz, Tj_siz, Tx_siz,
+     724             :                 T_iso, /* T is jumbled: */ true, NULL)) ;
+     725             : 
+     726             :         // restore G->A
+     727           4 :         G->A = S ;
+     728             : 
+     729             :     }
+     730             :     else
+     731             :     {
+     732             : 
+     733             :         // no sampling; the final phase operates on the whole graph
+     734          20 :         T = S ;
+     735             : 
+     736             :     }
+     737             : 
+     738             :     //--------------------------------------------------------------------------
+     739             :     // final phase
+     740             :     //--------------------------------------------------------------------------
+     741             : 
+     742          24 :     GRB_TRY (GrB_Matrix_nvals (&nnz, T)) ;
+     743             : 
+     744          24 :     bool change = true ;
+     745          96 :     while (change && nnz > 0)
+     746             :     {
+     747             :         // hooking & shortcutting
+     748          72 :         GRB_TRY (GrB_mxv (mngp, NULL, GrB_MIN_UINT32,
+     749             :                           GrB_MIN_SECOND_SEMIRING_UINT32, T, gp, NULL)) ;
+     750          72 :         GRB_TRY (Reduce_assign32 (&f, &mngp, V32, n, nthreads, ht_key,
+     751             :                                   ht_val, &seed, msg)) ;
+     752          72 :         GRB_TRY (GrB_eWiseAdd (f, NULL, GrB_MIN_UINT32, GrB_MIN_UINT32,
+     753             :                                mngp, gp, NULL)) ;
+     754             : 
+     755             :         // calculate grandparent
+     756             :         // fixme: NULL parameter is SS:GrB extension
+     757          72 :         GRB_TRY (GrB_Vector_extractTuples (NULL, V32, &n, f)) ; // fixme
+     758             :         int32_t k;
+     759             :         #pragma omp parallel for num_threads(nthreads2) schedule(static)
+     760       45924 :         for (k = 0 ; k < n ; k++)
+     761             :         {
+     762       45852 :             I [k] = (GrB_Index) V32 [k] ;
+     763             :         }
+     764          72 :         GRB_TRY (GrB_extract (gp_new, NULL, NULL, f, I, n, NULL)) ;
+     765             : 
+     766             :         // check termination
+     767          72 :         GRB_TRY (GrB_eWiseMult (mod, NULL, NULL, GrB_NE_UINT32, gp_new, gp,
+     768             :             NULL)) ;
+     769          72 :         GRB_TRY (GrB_reduce (&change, NULL, GrB_LOR_MONOID_BOOL, mod, NULL)) ;
+     770             : 
+     771             :         // swap gp and gp_new
+     772          72 :         GrB_Vector t = gp ; gp = gp_new ; gp_new = t ;
+     773             :     }
+     774             : 
+     775             :     //--------------------------------------------------------------------------
+     776             :     // free workspace and return result
+     777             :     //--------------------------------------------------------------------------
+     778             : 
+     779          24 :     (*component) = f ;
+     780          24 :     f = NULL ;
+     781          24 :     if (sampling)
+     782             :     {
+     783           4 :         GrB_free (&T) ;
+     784             :     }
+     785          24 :     LG_FREE_ALL ;
+     786          24 :     return (GrB_SUCCESS) ;
+     787             : #endif
+     788             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/index-sort-f.html b/experimental/algorithm/index-sort-f.html new file mode 100644 index 0000000000..d68c7cf2bc --- /dev/null +++ b/experimental/algorithm/index-sort-f.html @@ -0,0 +1,353 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithmHitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:20572057100.0 %
Date:2024-08-29 20:08:04Functions:6060100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
LAGraph_cdlp.c +
100.0%
+
100.0 %93 / 93100.0 %1 / 1
LAGraph_BF_pure_c.c +
100.0%
+
100.0 %36 / 36100.0 %1 / 1
LAGraph_BF_basic.c +
100.0%
+
100.0 %37 / 37100.0 %1 / 1
LAGraph_KCore.c +
100.0%
+
100.0 %44 / 44100.0 %1 / 1
LAGraph_BF_basic_mxv.c +
100.0%
+
100.0 %33 / 33100.0 %1 / 1
LAGraph_HelloWorld.c +
100.0%
+
100.0 %12 / 12100.0 %1 / 1
LAGraph_AllKTruss.c +
100.0%
+
100.0 %45 / 45100.0 %1 / 1
LAGraph_VertexCentrality_Triangle.c +
100.0%
+
100.0 %68 / 68100.0 %1 / 1
LAGraph_AllKCore.c +
100.0%
+
100.0 %49 / 49100.0 %1 / 1
LAGraph_SquareClustering.c +
100.0%
+
100.0 %39 / 39100.0 %1 / 1
LAGraph_BF_basic_pushpull.c +
100.0%
+
100.0 %69 / 69100.0 %1 / 1
LAGraph_KCoreDecompose.c +
100.0%
+
100.0 %25 / 25100.0 %1 / 1
LAGraph_MaximalIndependentSet.c +
100.0%
+
100.0 %81 / 81100.0 %1 / 1
LAGraph_dnn.c +
100.0%
+
100.0 %16 / 16100.0 %1 / 1
LAGraph_BF_pure_c_double.c +
100.0%
+
100.0 %36 / 36100.0 %1 / 1
LAGraph_KTruss.c +
100.0%
+
100.0 %24 / 24100.0 %1 / 1
LAGraph_cc_lacc.c +
100.0%
+
100.0 %110 / 110100.0 %2 / 2
LAGraph_FastGraphletTransform.c +
100.0%
+
100.0 %242 / 242100.0 %2 / 2
LAGraph_lcc.c +
100.0%
+
100.0 %67 / 67100.0 %3 / 3
LAGraph_BF_full2.c +
100.0%
+
100.0 %100 / 100100.0 %4 / 4
LAGraph_BF_full_mxv.c +
100.0%
+
100.0 %94 / 94100.0 %4 / 4
LAGraph_scc.c +
100.0%
+
100.0 %103 / 103100.0 %4 / 4
LAGraph_BF_full1a.c +
100.0%
+
100.0 %100 / 100100.0 %4 / 4
LAGraph_BF_full.c +
100.0%
+
100.0 %89 / 89100.0 %4 / 4
LG_CC_FastSV5.c +
100.0%
+
100.0 %203 / 203100.0 %5 / 5
LAGraph_BF_full1.c +
100.0%
+
100.0 %112 / 112100.0 %5 / 5
LAGraph_msf.c +
100.0%
+
100.0 %130 / 130100.0 %7 / 7
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/index-sort-l.html b/experimental/algorithm/index-sort-l.html new file mode 100644 index 0000000000..4b6ac12733 --- /dev/null +++ b/experimental/algorithm/index-sort-l.html @@ -0,0 +1,353 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithmHitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:20572057100.0 %
Date:2024-08-29 20:08:04Functions:6060100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
LAGraph_HelloWorld.c +
100.0%
+
100.0 %12 / 12100.0 %1 / 1
LAGraph_dnn.c +
100.0%
+
100.0 %16 / 16100.0 %1 / 1
LAGraph_KTruss.c +
100.0%
+
100.0 %24 / 24100.0 %1 / 1
LAGraph_KCoreDecompose.c +
100.0%
+
100.0 %25 / 25100.0 %1 / 1
LAGraph_BF_basic_mxv.c +
100.0%
+
100.0 %33 / 33100.0 %1 / 1
LAGraph_BF_pure_c.c +
100.0%
+
100.0 %36 / 36100.0 %1 / 1
LAGraph_BF_pure_c_double.c +
100.0%
+
100.0 %36 / 36100.0 %1 / 1
LAGraph_BF_basic.c +
100.0%
+
100.0 %37 / 37100.0 %1 / 1
LAGraph_SquareClustering.c +
100.0%
+
100.0 %39 / 39100.0 %1 / 1
LAGraph_KCore.c +
100.0%
+
100.0 %44 / 44100.0 %1 / 1
LAGraph_AllKTruss.c +
100.0%
+
100.0 %45 / 45100.0 %1 / 1
LAGraph_AllKCore.c +
100.0%
+
100.0 %49 / 49100.0 %1 / 1
LAGraph_lcc.c +
100.0%
+
100.0 %67 / 67100.0 %3 / 3
LAGraph_VertexCentrality_Triangle.c +
100.0%
+
100.0 %68 / 68100.0 %1 / 1
LAGraph_BF_basic_pushpull.c +
100.0%
+
100.0 %69 / 69100.0 %1 / 1
LAGraph_MaximalIndependentSet.c +
100.0%
+
100.0 %81 / 81100.0 %1 / 1
LAGraph_BF_full.c +
100.0%
+
100.0 %89 / 89100.0 %4 / 4
LAGraph_cdlp.c +
100.0%
+
100.0 %93 / 93100.0 %1 / 1
LAGraph_BF_full_mxv.c +
100.0%
+
100.0 %94 / 94100.0 %4 / 4
LAGraph_BF_full2.c +
100.0%
+
100.0 %100 / 100100.0 %4 / 4
LAGraph_BF_full1a.c +
100.0%
+
100.0 %100 / 100100.0 %4 / 4
LAGraph_scc.c +
100.0%
+
100.0 %103 / 103100.0 %4 / 4
LAGraph_cc_lacc.c +
100.0%
+
100.0 %110 / 110100.0 %2 / 2
LAGraph_BF_full1.c +
100.0%
+
100.0 %112 / 112100.0 %5 / 5
LAGraph_msf.c +
100.0%
+
100.0 %130 / 130100.0 %7 / 7
LG_CC_FastSV5.c +
100.0%
+
100.0 %203 / 203100.0 %5 / 5
LAGraph_FastGraphletTransform.c +
100.0%
+
100.0 %242 / 242100.0 %2 / 2
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/algorithm/index.html b/experimental/algorithm/index.html new file mode 100644 index 0000000000..f058823ccc --- /dev/null +++ b/experimental/algorithm/index.html @@ -0,0 +1,353 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/algorithm + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/algorithmHitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:20572057100.0 %
Date:2024-08-29 20:08:04Functions:6060100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
LAGraph_AllKCore.c +
100.0%
+
100.0 %49 / 49100.0 %1 / 1
LAGraph_AllKTruss.c +
100.0%
+
100.0 %45 / 45100.0 %1 / 1
LAGraph_BF_basic.c +
100.0%
+
100.0 %37 / 37100.0 %1 / 1
LAGraph_BF_basic_mxv.c +
100.0%
+
100.0 %33 / 33100.0 %1 / 1
LAGraph_BF_basic_pushpull.c +
100.0%
+
100.0 %69 / 69100.0 %1 / 1
LAGraph_BF_full.c +
100.0%
+
100.0 %89 / 89100.0 %4 / 4
LAGraph_BF_full1.c +
100.0%
+
100.0 %112 / 112100.0 %5 / 5
LAGraph_BF_full1a.c +
100.0%
+
100.0 %100 / 100100.0 %4 / 4
LAGraph_BF_full2.c +
100.0%
+
100.0 %100 / 100100.0 %4 / 4
LAGraph_BF_full_mxv.c +
100.0%
+
100.0 %94 / 94100.0 %4 / 4
LAGraph_BF_pure_c.c +
100.0%
+
100.0 %36 / 36100.0 %1 / 1
LAGraph_BF_pure_c_double.c +
100.0%
+
100.0 %36 / 36100.0 %1 / 1
LAGraph_FastGraphletTransform.c +
100.0%
+
100.0 %242 / 242100.0 %2 / 2
LAGraph_HelloWorld.c +
100.0%
+
100.0 %12 / 12100.0 %1 / 1
LAGraph_KCore.c +
100.0%
+
100.0 %44 / 44100.0 %1 / 1
LAGraph_KCoreDecompose.c +
100.0%
+
100.0 %25 / 25100.0 %1 / 1
LAGraph_KTruss.c +
100.0%
+
100.0 %24 / 24100.0 %1 / 1
LAGraph_MaximalIndependentSet.c +
100.0%
+
100.0 %81 / 81100.0 %1 / 1
LAGraph_SquareClustering.c +
100.0%
+
100.0 %39 / 39100.0 %1 / 1
LAGraph_VertexCentrality_Triangle.c +
100.0%
+
100.0 %68 / 68100.0 %1 / 1
LAGraph_cc_lacc.c +
100.0%
+
100.0 %110 / 110100.0 %2 / 2
LAGraph_cdlp.c +
100.0%
+
100.0 %93 / 93100.0 %1 / 1
LAGraph_dnn.c +
100.0%
+
100.0 %16 / 16100.0 %1 / 1
LAGraph_lcc.c +
100.0%
+
100.0 %67 / 67100.0 %3 / 3
LAGraph_msf.c +
100.0%
+
100.0 %130 / 130100.0 %7 / 7
LAGraph_scc.c +
100.0%
+
100.0 %103 / 103100.0 %4 / 4
LG_CC_FastSV5.c +
100.0%
+
100.0 %203 / 203100.0 %5 / 5
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/LG_check_kcore.c.func-sort-c.html b/experimental/test/LG_check_kcore.c.func-sort-c.html new file mode 100644 index 0000000000..fdf770a126 --- /dev/null +++ b/experimental/test/LG_check_kcore.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/LG_check_kcore.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - LG_check_kcore.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:6565100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_check_kcore4
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/LG_check_kcore.c.func.html b/experimental/test/LG_check_kcore.c.func.html new file mode 100644 index 0000000000..b5073f38f6 --- /dev/null +++ b/experimental/test/LG_check_kcore.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/LG_check_kcore.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - LG_check_kcore.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:6565100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_check_kcore4
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/LG_check_kcore.c.gcov.html b/experimental/test/LG_check_kcore.c.gcov.html new file mode 100644 index 0000000000..05c50ece9a --- /dev/null +++ b/experimental/test/LG_check_kcore.c.gcov.html @@ -0,0 +1,258 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/LG_check_kcore.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - LG_check_kcore.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:6565100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LG_check_kcore: construct the kcore of a graph (simple method)
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Pranav Konduri, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // An implementation of the BZ algorithm (2003) for k-core decomposition.
+      19             : // This method is for testing only, to check the result of other, faster methods.
+      20             : // Do not benchmark this method; it is simple by design.
+      21             : 
+      22             : #define LG_FREE_ALL                             \
+      23             : {                                               \
+      24             :     LAGraph_Free ((void **) &vert, msg) ;       \
+      25             :     LAGraph_Free ((void **) &deg, msg) ;        \
+      26             :     LAGraph_Free ((void **) &bin, msg) ;        \
+      27             :     LAGraph_Free ((void **) &pos, msg) ;        \
+      28             :     LAGraph_Free ((void **) &Ap, msg) ;         \
+      29             :     LAGraph_Free ((void **) &Aj, msg) ;         \
+      30             :     LAGraph_Free ((void **) &Ax, msg) ;         \
+      31             : }
+      32             : 
+      33             : #include "LG_internal.h"
+      34             : #include "LG_test.h"
+      35             : #include "LG_test.h"
+      36             : #include "LG_Xtest.h"
+      37             : 
+      38           4 : int LG_check_kcore
+      39             : (
+      40             :     // outputs:
+      41             :     GrB_Vector *decomp,     // kcore decomposition
+      42             :     uint64_t *kmax,         // max kcore- if kfinal == -1, kmax = -1
+      43             :     // inputs
+      44             :     LAGraph_Graph G,        // input graph
+      45             :     int64_t kfinal,         // max k to check for graph.
+      46             :     char *msg
+      47             : )
+      48             : {
+      49             : 
+      50             :     //--------------------------------------------------------------------------
+      51             :     // check inputs
+      52             :     //--------------------------------------------------------------------------
+      53             : 
+      54           4 :     LG_CLEAR_MSG ;
+      55           4 :     uint64_t *vert = NULL, *pos = NULL, *bin = NULL, *deg = NULL ;
+      56           4 :     uint64_t maxDeg = 0;
+      57           4 :     GrB_Index *Ap = NULL, *Aj = NULL, *Ai = NULL ;
+      58           4 :     void *Ax = NULL ;
+      59             :     GrB_Index Ap_size, Aj_size, Ax_size, n, ncols, Ap_len, Aj_len, Ax_len ;
+      60           4 :     LG_ASSERT (kmax != NULL, GrB_NULL_POINTER) ;
+      61           4 :     LG_TRY (LAGraph_CheckGraph (G, msg)) ;
+      62           4 :     LG_ASSERT (G->nself_edges == 0, LAGRAPH_NO_SELF_EDGES_ALLOWED) ;
+      63           4 :     LG_ASSERT_MSG ((G->kind == LAGraph_ADJACENCY_UNDIRECTED ||
+      64             :        (G->kind == LAGraph_ADJACENCY_DIRECTED &&
+      65             :         G->is_symmetric_structure == LAGraph_TRUE)),
+      66             :         LAGRAPH_SYMMETRIC_STRUCTURE_REQUIRED,
+      67             :         "G->A must be known to be symmetric") ;
+      68           4 :     GRB_TRY (GrB_Matrix_nrows (&n, G->A)) ; //set n to number of rows
+      69           4 :     GRB_TRY (GrB_Matrix_ncols (&ncols, G->A)) ;
+      70             : 
+      71             :     //--------------------------------------------------------------------------
+      72             :     // export the matrix in CSR form
+      73             :     //--------------------------------------------------------------------------
+      74             : 
+      75             :     size_t typesize ;
+      76           4 :     LG_TRY (LG_check_export (G, &Ap, &Aj, &Ax, &Ap_len, &Aj_len, &Ax_len,
+      77             :         &typesize, msg)) ;
+      78             : 
+      79             :     //--------------------------------------------------------------------------
+      80             :     // compute the k-core
+      81             :     //--------------------------------------------------------------------------
+      82             :     //printf ("\n================================== COMPUTING BZ_KCORE: ==================================\n") ;
+      83             :     //printf("ap_len = %ld, aj_len = %ld, ax_len = %ld\n", Ap_len, Aj_len, Ax_len) ;
+      84             : 
+      85             :     //create the arrays
+      86             : 
+      87           4 :     LAGraph_Malloc((void **) &deg, n, sizeof(uint64_t), msg) ;
+      88           4 :     LAGraph_Malloc((void **) &vert, n, sizeof(uint64_t), msg) ;
+      89           4 :     LAGraph_Malloc((void **) &pos, n, sizeof(uint64_t), msg) ;
+      90             :     //core = AGraph_Malloc(n, sizeof(uint64_t)) ;
+      91             : 
+      92         206 :     for(uint64_t i = 0; i < n; i++){
+      93         202 :         deg[i] = Ap[i+1] - Ap[i];
+      94         202 :         if (deg[i] > maxDeg)
+      95          12 :             maxDeg = deg[i];
+      96             :     }
+      97             : 
+      98             :     //setup output vector
+      99           4 :     GrB_Type int_type  = (maxDeg > INT32_MAX) ? GrB_INT64 : GrB_INT32 ;
+     100           4 :     GRB_TRY (GrB_Vector_new(decomp, int_type, n)) ;
+     101           4 :     GrB_IndexUnaryOp valueGE = (maxDeg > INT32_MAX) ? GrB_VALUEGE_INT64 : GrB_VALUEGE_INT32 ;
+     102             : 
+     103             :     //setup bin array
+     104           4 :     LAGraph_Calloc((void **) &bin, maxDeg + 1, sizeof(uint64_t), msg) ;
+     105             : 
+     106         206 :     for(uint64_t i = 0; i < n; i++){
+     107         202 :         bin[deg[i]]++;
+     108             :     }
+     109             : 
+     110           4 :     uint64_t start = 0;
+     111          74 :     for(uint64_t d = 0; d < maxDeg + 1; d++){
+     112          70 :         uint64_t num = bin[d];
+     113          70 :         bin[d] = start;
+     114          70 :         start = start + num;
+     115             :     }
+     116             : 
+     117             :     //Do bin-sort
+     118             :     //vert -- contains the vertices in sorted order of degree
+     119             :     //pos -- contains the positon of a vertex in vert array
+     120         206 :     for(uint64_t i = 0; i < n; i++){
+     121         202 :         pos[i] = bin[ deg[i] ];
+     122         202 :         vert[pos[i]] = i;
+     123         202 :         bin[deg[i]] ++;
+     124             :     }
+     125             : 
+     126          70 :     for(uint64_t d = maxDeg; d >= 1; d --)
+     127          66 :         bin[d] = bin[d-1];
+     128           4 :     bin[0] = 0;
+     129             : 
+     130           4 :     uint64_t level = 0;
+     131             : 
+     132             :     //Compute k-core
+     133         206 :     for(uint64_t i = 0; i < n; i++){
+     134             :         //get the vertex to check
+     135         202 :         uint64_t v = vert[i];
+     136             : 
+     137             :         //set the element in the output vector: if doing KCALL, then add deg.
+     138             :         //If not, just set to kfinal's value.
+     139         202 :         if((int64_t) deg[v] >= kfinal){
+     140         201 :             if(kfinal == -1){
+     141         101 :                 GRB_TRY(GrB_Vector_setElement(*decomp, deg[v], v)) ;
+     142             :             }
+     143             :             else{
+     144         100 :                 GRB_TRY(GrB_Vector_setElement(*decomp, kfinal, v)) ;
+     145             :             }
+     146             :         }
+     147             : 
+     148         202 :         if(bin[deg[v]] == i){
+     149          12 :             level = deg[v];
+     150             :         }
+     151             : 
+     152         202 :         uint64_t start = Ap[v];
+     153         202 :         int64_t original_deg = Ap[v+1] - Ap[v]; //original deg before decremented
+     154        1662 :         for(uint64_t j = 0; j < original_deg; j++){
+     155        1460 :             uint64_t u = Aj[start + j]; //a neighbor node of v
+     156             : 
+     157             :             //if we need to lower the neighbor's deg value, and relocate in bin
+     158        1460 :             if(deg[u] > deg[v]){
+     159         462 :                 uint64_t du = deg[u];
+     160         462 :                 uint64_t pu = pos[u];
+     161         462 :                 uint64_t pw = bin[du];
+     162         462 :                 uint64_t w = vert[pw]; //the vertex situated at the beginning of the bin
+     163             : 
+     164             :                 //swap around the vertices- w goes to the end, u goes to the beginning
+     165         462 :                 if(u != w){
+     166         296 :                     pos[u] = pw; vert[pu] = w;
+     167         296 :                     pos[w] = pu; vert[pw] = u;
+     168             :                 }
+     169             : 
+     170             :                 //increase starting index of bin @ du
+     171         462 :                 bin[du]++;
+     172             :                 //decrease degree of u
+     173         462 :                 deg[u]--;
+     174             :             }
+     175             :         }
+     176             :     }
+     177             : 
+     178           4 :     LG_FREE_ALL;
+     179           4 :     (*kmax) = level ;
+     180           4 :     GRB_TRY (GrB_Vector_wait(*decomp, GrB_MATERIALIZE));
+     181           4 :     return (GrB_SUCCESS);
+     182             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/LG_check_kcoredecompose.c.func-sort-c.html b/experimental/test/LG_check_kcoredecompose.c.func-sort-c.html new file mode 100644 index 0000000000..65e7794d0f --- /dev/null +++ b/experimental/test/LG_check_kcoredecompose.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/LG_check_kcoredecompose.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - LG_check_kcoredecompose.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3939100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_check_kcore_decompose3
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/LG_check_kcoredecompose.c.func.html b/experimental/test/LG_check_kcoredecompose.c.func.html new file mode 100644 index 0000000000..ee3c4ba4b5 --- /dev/null +++ b/experimental/test/LG_check_kcoredecompose.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/LG_check_kcoredecompose.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - LG_check_kcoredecompose.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3939100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_check_kcore_decompose3
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/LG_check_kcoredecompose.c.gcov.html b/experimental/test/LG_check_kcoredecompose.c.gcov.html new file mode 100644 index 0000000000..15f7fdc0af --- /dev/null +++ b/experimental/test/LG_check_kcoredecompose.c.gcov.html @@ -0,0 +1,192 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/LG_check_kcoredecompose.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - LG_check_kcoredecompose.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3939100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LG_check_kcoredecompose: deconstruct the graph into a k-core, given a
+       3             : // decompostion vector (simple method)
+       4             : //------------------------------------------------------------------------------
+       5             : 
+       6             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       7             : // SPDX-License-Identifier: BSD-2-Clause
+       8             : //
+       9             : // For additional details (including references to third party source code and
+      10             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      11             : // Contributors.txt for a full list of contributors. Created, in part, with
+      12             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      13             : // DM22-0790
+      14             : 
+      15             : // Contributed by Pranav Konduri, Texas A&M University
+      16             : 
+      17             : //------------------------------------------------------------------------------
+      18             : 
+      19             : // This method is for testing only, to check the result of other, faster methods.
+      20             : // Do not benchmark this method; it is slow and simple by design.
+      21             : 
+      22             : #define LG_FREE_WORK                \
+      23             : {                                   \
+      24             :     GrB_free (&C) ;                 \
+      25             :     GrB_free (&deg) ;               \
+      26             : }
+      27             : 
+      28             : #define LG_FREE_ALL                 \
+      29             : {                                   \
+      30             :     LG_FREE_WORK                    \
+      31             :     GrB_free (D) ;                  \
+      32             : }
+      33             : 
+      34             : 
+      35             : #include "LG_internal.h"
+      36             : #include "LG_test.h"
+      37             : #include "LG_Xtest.h"
+      38             : 
+      39           3 : int LG_check_kcore_decompose
+      40             : (
+      41             :     // outputs:
+      42             :     GrB_Matrix *D,              // kcore decomposition
+      43             :     // inputs:
+      44             :     LAGraph_Graph G,            // input graph
+      45             :     GrB_Vector decomp,
+      46             :     uint64_t k,
+      47             :     char *msg
+      48             : )
+      49             : {
+      50           3 :     LG_CLEAR_MSG ;
+      51             : 
+      52             :     // declare items
+      53           3 :     GrB_Matrix A = NULL, C = NULL;
+      54           3 :     GrB_Vector deg = NULL;
+      55             : 
+      56           3 :     LG_ASSERT (D != NULL, GrB_NULL_POINTER) ;
+      57           3 :     (*D) = NULL ;
+      58             : 
+      59           3 :     LG_TRY (LAGraph_CheckGraph (G, msg)) ;
+      60             : 
+      61           3 :     if (G->kind == LAGraph_ADJACENCY_UNDIRECTED ||
+      62           2 :        (G->kind == LAGraph_ADJACENCY_DIRECTED &&
+      63           2 :         G->is_symmetric_structure == LAGraph_TRUE))
+      64             :     {
+      65             :          // the structure of A is known to be symmetric
+      66           2 :         A = G->A ;
+      67             :     }
+      68             :     else
+      69             :     {
+      70             :         // A is not known to be symmetric
+      71           1 :         LG_ASSERT_MSG (false, -1005, "G->A must be symmetric") ;
+      72             :     }
+      73             : 
+      74             :     // no self edges can be present
+      75           2 :     LG_ASSERT_MSG (G->nself_edges == 0, -1004, "G->nself_edges must be zero") ;
+      76             : 
+      77             :     //create work scalars
+      78             :     GrB_Index size_matrix, nvals_matrix, size_vector, nvals_vector;
+      79           2 :     GRB_TRY (GrB_Matrix_nrows(&size_matrix, A)) ;
+      80           2 :     GRB_TRY (GrB_Vector_size(&size_vector, decomp)) ;
+      81             : 
+      82           2 :     LG_ASSERT_MSG (size_matrix == size_vector, -1003, "Size of vector and of matrix must be same") ;
+      83             : 
+      84             :     //create D and nvals scalars
+      85           2 :     GRB_TRY (GrB_Matrix_new(D, GrB_INT64, size_matrix, size_matrix)) ;
+      86           2 :     GRB_TRY (GrB_Matrix_nvals(&nvals_matrix, A)) ;
+      87           2 :     GRB_TRY (GrB_Vector_nvals(&nvals_vector, decomp));
+      88             : 
+      89             :     //extract out the values of the input graph
+      90           2 :     GrB_Index *row = NULL, *col = NULL , *matrix_values = NULL, *vector = NULL, *vector_values = NULL;
+      91           2 :     LG_TRY (LAGraph_Malloc ((void **) &row, nvals_matrix, sizeof (GrB_Index), msg));
+      92           2 :     LG_TRY (LAGraph_Malloc ((void **) &col, nvals_matrix, sizeof (GrB_Index), msg));
+      93           2 :     LG_TRY (LAGraph_Malloc ((void **) &matrix_values, nvals_matrix, sizeof (GrB_Index), msg));
+      94             : 
+      95           2 :     LG_TRY (LAGraph_Malloc ((void **) &vector, nvals_vector, sizeof (GrB_Index), msg));
+      96           2 :     LG_TRY (LAGraph_Malloc ((void **) &vector_values, nvals_vector, sizeof (GrB_Index), msg));
+      97             : 
+      98           2 :     GRB_TRY(GrB_Matrix_extractTuples(row, col, (int64_t *) matrix_values, &nvals_matrix, A));
+      99           2 :     GRB_TRY(GrB_Vector_extractTuples(vector, (int64_t *) vector_values, &size_vector, decomp));
+     100             :     //take all values that have row and col indices
+     101         732 :     for(uint64_t i = 0; i < nvals_matrix; i++){
+     102         730 :         bool ok_row = false, ok_col = false;
+     103       25952 :         for(uint64_t j = 0; (j < nvals_vector) && (!ok_row || !ok_col); j++){
+     104       25222 :             if(row[i] == vector[j] && vector_values[j] >= k)
+     105         651 :                 ok_row = true;
+     106       25222 :             if(col[i] == vector[j] && vector_values[j] >= k)
+     107         651 :                 ok_col = true;
+     108             :         }
+     109         730 :         if(ok_row && ok_col){
+     110         604 :             GRB_TRY(GrB_Matrix_setElement(*D, matrix_values[i], row[i], col[i]));
+     111             :         }
+     112             :     }
+     113           2 :     LG_FREE_WORK;
+     114           2 :     GRB_TRY (GrB_Matrix_wait(*D, GrB_MATERIALIZE));
+     115           2 :     return (GrB_SUCCESS);
+     116             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/LG_check_ktruss.c.func-sort-c.html b/experimental/test/LG_check_ktruss.c.func-sort-c.html new file mode 100644 index 0000000000..6f7b1a7eb3 --- /dev/null +++ b/experimental/test/LG_check_ktruss.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/LG_check_ktruss.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - LG_check_ktruss.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:4949100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_check_ktruss30
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/LG_check_ktruss.c.func.html b/experimental/test/LG_check_ktruss.c.func.html new file mode 100644 index 0000000000..516e121066 --- /dev/null +++ b/experimental/test/LG_check_ktruss.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/LG_check_ktruss.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - LG_check_ktruss.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:4949100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_check_ktruss30
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/LG_check_ktruss.c.gcov.html b/experimental/test/LG_check_ktruss.c.gcov.html new file mode 100644 index 0000000000..b7bbbba6cc --- /dev/null +++ b/experimental/test/LG_check_ktruss.c.gcov.html @@ -0,0 +1,256 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/LG_check_ktruss.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - LG_check_ktruss.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:4949100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LG_check_ktruss: construct the ktruss of a graph (simple method)
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // A very slow, bare-bones ktruss method.  This method is for testing only, to
+      19             : // check the result of other, faster methods.  Do not benchmark this method; it
+      20             : // is slow and simple by design.  G->A must be symmetric, with no entries on
+      21             : // its diagonal.
+      22             : 
+      23             : #define LG_FREE_WORK                            \
+      24             : {                                               \
+      25             :     LAGraph_Free ((void **) &Cp, NULL) ;        \
+      26             :     LAGraph_Free ((void **) &Cj, NULL) ;        \
+      27             :     LAGraph_Free ((void **) &Cx, NULL) ;        \
+      28             :     LAGraph_Free ((void **) &Ax, NULL) ;        \
+      29             : }
+      30             : 
+      31             : #define LG_FREE_ALL                             \
+      32             : {                                               \
+      33             :     LG_FREE_WORK ;                              \
+      34             :     GrB_free (&C) ;                             \
+      35             : }
+      36             : 
+      37             : #include "LG_internal.h"
+      38             : #include "LG_test.h"
+      39             : 
+      40          30 : int LG_check_ktruss
+      41             : (
+      42             :     // output
+      43             :     GrB_Matrix *C_handle,   // the ktruss of G->A, of type GrB_UINT32
+      44             :     // input
+      45             :     LAGraph_Graph G,        // the structure of G->A must be symmetric
+      46             :     uint32_t k,
+      47             :     char *msg
+      48             : )
+      49             : {
+      50             : 
+      51             :     //--------------------------------------------------------------------------
+      52             :     // check inputs
+      53             :     //--------------------------------------------------------------------------
+      54             : 
+      55          30 :     LG_CLEAR_MSG ;
+      56             : 
+      57          30 :     GrB_Matrix C = NULL ;
+      58          30 :     GrB_Index *Cp = NULL, *Cj = NULL ;
+      59          30 :     uint32_t *Cx = NULL ;
+      60          30 :     void *Ax = NULL ;
+      61             :     GrB_Index n, ncols, Cp_len, Cj_len, Cx_len, nvals1, nvals2 ;
+      62          30 :     LG_ASSERT (C_handle != NULL, GrB_NULL_POINTER) ;
+      63          30 :     LG_TRY (LAGraph_CheckGraph (G, msg)) ;
+      64          30 :     LG_ASSERT_MSG (G->nself_edges == 0, -104, "G->nself_edges must be zero") ;
+      65          30 :     if (G->kind == LAGraph_ADJACENCY_UNDIRECTED ||
+      66           9 :        (G->kind == LAGraph_ADJACENCY_DIRECTED &&
+      67           9 :         G->is_symmetric_structure == LAGraph_TRUE))
+      68             :     {
+      69             :         // the structure of A is known to be symmetric
+      70             :         ;
+      71             :     }
+      72             :     else
+      73             :     {
+      74             :         // A is not known to be symmetric
+      75           1 :         LG_ASSERT_MSG (false, -1005, "G->A must be symmetric") ;
+      76             :     }
+      77          29 :     GRB_TRY (GrB_Matrix_nrows (&n, G->A)) ;
+      78          29 :     GRB_TRY (GrB_Matrix_ncols (&ncols, G->A)) ;
+      79          29 :     LG_ASSERT_MSG (n == ncols, -1001, "A must be square") ;
+      80             : 
+      81             :     //--------------------------------------------------------------------------
+      82             :     // export G->A in CSR form and discard its values
+      83             :     //--------------------------------------------------------------------------
+      84             : 
+      85             :     size_t typesize ;
+      86          29 :     LG_TRY (LG_check_export (G, &Cp, &Cj, &Ax, &Cp_len, &Cj_len, &Cx_len,
+      87             :         &typesize, msg)) ;
+      88          29 :     LAGraph_Free ((void **) &Ax, NULL) ;
+      89             : 
+      90             :     //--------------------------------------------------------------------------
+      91             :     // allocate Cx
+      92             :     //--------------------------------------------------------------------------
+      93             : 
+      94          29 :     LG_TRY (LAGraph_Malloc ((void **) &Cx, Cx_len, sizeof (uint32_t), msg)) ;
+      95             : 
+      96             :     //--------------------------------------------------------------------------
+      97             :     // construct the k-truss of G->A
+      98             :     //--------------------------------------------------------------------------
+      99             : 
+     100             :     while (true)
+     101          47 :     {
+     102             : 
+     103             :         //----------------------------------------------------------------------
+     104             :         // compute the # of triangles incident on each edge of C
+     105             :         //----------------------------------------------------------------------
+     106             : 
+     107             :         // masked dot-product method: C{C}=C*C' using the PLUS_ONE semiring
+     108             :         int64_t i;
+     109             :         #if !defined ( COVERAGE )
+     110             :         #pragma omp parallel for schedule(dynamic,1024)
+     111             :         #endif
+     112       19130 :         for (i = 0 ; i < n ; i++)
+     113             :         {
+     114             :             // for each entry in C(i,:)
+     115       63472 :             for (int64_t p = Cp [i] ; p < Cp [i+1] ; p++)
+     116             :             {
+     117       44418 :                 const int64_t j = Cj [p] ;
+     118       44418 :                 uint32_t cij = 0 ;
+     119             :                 // cij += C(i,:) * C(j,:)'
+     120       44418 :                 int64_t p1 = Cp [i] ;
+     121       44418 :                 int64_t p1_end = Cp [i+1] ;
+     122       44418 :                 int64_t p2 = Cp [j] ;
+     123       44418 :                 int64_t p2_end = Cp [j+1] ;
+     124      391970 :                 while (p1 < p1_end && p2 < p2_end)
+     125             :                 {
+     126      347552 :                     int64_t j1 = Cj [p1] ;
+     127      347552 :                     int64_t j2 = Cj [p2] ;
+     128      347552 :                     if (j1 < j2)
+     129             :                     {
+     130             :                         // C(i,j1) appears before C(j,j2)
+     131      133513 :                         p1++ ;
+     132             :                     }
+     133      214039 :                     else if (j2 < j1)
+     134             :                     {
+     135             :                         // C(j,j2) appears before C(i,j1)
+     136      133513 :                         p2++ ;
+     137             :                     }
+     138             :                     else // j1 == j2
+     139             :                     {
+     140             :                         // C(i,j1) and C(j,j1) are the next entries to merge
+     141       80526 :                         cij++ ;
+     142       80526 :                         p1++ ;
+     143       80526 :                         p2++ ;
+     144             :                     }
+     145             :                 }
+     146       44418 :                 Cx [p] = cij ;
+     147             :             }
+     148             :         }
+     149             : 
+     150             :         //----------------------------------------------------------------------
+     151             :         // import C in CSR form
+     152             :         //----------------------------------------------------------------------
+     153             : 
+     154          76 :         GRB_TRY (GrB_Matrix_import_UINT32 (&C, GrB_UINT32, n, n,
+     155             :             Cp, Cj, Cx, Cp_len, Cj_len, Cx_len, GrB_CSR_FORMAT)) ;
+     156          76 :         GRB_TRY (GrB_Matrix_nvals (&nvals1, C)) ;
+     157             : 
+     158             :         //----------------------------------------------------------------------
+     159             :         // keep entries >= k-2 and check for convergence
+     160             :         //----------------------------------------------------------------------
+     161             : 
+     162          76 :         GRB_TRY (GrB_select (C, NULL, NULL, GrB_VALUEGE_UINT32, C, k-2, NULL)) ;
+     163          76 :         GRB_TRY (GrB_Matrix_nvals (&nvals2, C)) ;
+     164          76 :         if (nvals1 == nvals2)
+     165             :         {
+     166             :             // C is now the k-truss of G->A
+     167          29 :             LG_FREE_WORK ;
+     168          29 :             (*C_handle) = C ;
+     169          29 :             return (GrB_SUCCESS) ;
+     170             :         }
+     171             : 
+     172             :         //----------------------------------------------------------------------
+     173             :         // export C in CSR form for the next iteration and free it
+     174             :         //----------------------------------------------------------------------
+     175             : 
+     176          47 :         GRB_TRY (GrB_Matrix_export_UINT32 (Cp, Cj, Cx,
+     177             :             &Cp_len, &Cj_len, &Cx_len, GrB_CSR_FORMAT, C)) ;
+     178          47 :         GRB_TRY (GrB_free (&C)) ;
+     179             :     }
+     180             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/LG_check_mis.c.func-sort-c.html b/experimental/test/LG_check_mis.c.func-sort-c.html new file mode 100644 index 0000000000..66e8000fc3 --- /dev/null +++ b/experimental/test/LG_check_mis.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/LG_check_mis.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - LG_check_mis.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3838100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_check_mis339
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/LG_check_mis.c.func.html b/experimental/test/LG_check_mis.c.func.html new file mode 100644 index 0000000000..2bf5ccc336 --- /dev/null +++ b/experimental/test/LG_check_mis.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/LG_check_mis.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - LG_check_mis.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3838100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_check_mis339
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/LG_check_mis.c.gcov.html b/experimental/test/LG_check_mis.c.gcov.html new file mode 100644 index 0000000000..d13c3b722e --- /dev/null +++ b/experimental/test/LG_check_mis.c.gcov.html @@ -0,0 +1,203 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/LG_check_mis.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - LG_check_mis.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3838100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LG_check_mis: test if iset is a maximal independent set
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #define LG_FREE_WORK                    \
+      19             : {                                       \
+      20             :     GrB_free (&C) ;                     \
+      21             :     LAGraph_Free ((void **) &I, NULL) ; \
+      22             :     LAGraph_Free ((void **) &X, NULL) ; \
+      23             : }
+      24             : 
+      25             : #define LG_FREE_ALL                     \
+      26             : {                                       \
+      27             :     LG_FREE_WORK ;                      \
+      28             : }
+      29             : 
+      30             : #include "LG_internal.h"
+      31             : #include "LG_test.h"
+      32             : 
+      33         339 : int LG_check_mis        // check if iset is a valid MIS of A
+      34             : (
+      35             :     GrB_Matrix A,
+      36             :     GrB_Vector iset,
+      37             :     GrB_Vector ignore_node,     // if NULL, no nodes are ignored.  otherwise,
+      38             :                         // ignore_node(i)=true if node i is to be ignored, and
+      39             :                         // not added to the independent set.
+      40             :     char *msg
+      41             : )
+      42             : {
+      43             : 
+      44             :     //--------------------------------------------------------------------------
+      45             :     // check and report the results
+      46             :     //--------------------------------------------------------------------------
+      47             : 
+      48         339 :     LG_CLEAR_MSG ;
+      49         339 :     GrB_Matrix C = NULL ;
+      50         339 :     GrB_Index *I = NULL ;
+      51         339 :     bool *X = NULL ;
+      52             : 
+      53             :     GrB_Index n ;
+      54         339 :     GRB_TRY (GrB_Matrix_nrows (&n, A)) ;
+      55             : 
+      56             :     int64_t isize ;
+      57         339 :     GRB_TRY (GrB_Vector_reduce_INT64 (&isize, NULL, GrB_PLUS_MONOID_INT64,
+      58             :         iset, NULL)) ;
+      59             : 
+      60             :     GrB_Index nvals ;
+      61         339 :     GRB_TRY (GrB_Vector_nvals (&nvals, iset)) ;
+      62         339 :     LAGRAPH_TRY (LAGraph_Malloc ((void **) &I, nvals, sizeof (GrB_Index), msg));
+      63         339 :     LAGRAPH_TRY (LAGraph_Malloc ((void **) &X, nvals, sizeof (bool), msg)) ;
+      64             : 
+      65         339 :     GRB_TRY (GrB_Vector_extractTuples_BOOL (I, X, &nvals, iset)) ;
+      66             : 
+      67             :     // I [0..isize-1] is the independent set
+      68         339 :     isize = 0 ;
+      69       46320 :     for (int64_t k = 0 ; k < nvals ; k++)
+      70             :     {
+      71       45981 :         if (X [k])
+      72             :         {
+      73       45981 :             I [isize++] = I [k] ;
+      74             :         }
+      75             :     }
+      76             : 
+      77         339 :     LAGraph_Free ((void **) &X, NULL) ;
+      78             : 
+      79             :     // printf ("independent set found: %.16g of %.16g nodes\n",
+      80             :     // (double) isize, (double) n) ;
+      81             : 
+      82             :     //--------------------------------------------------------------------------
+      83             :     // verify the result
+      84             :     //--------------------------------------------------------------------------
+      85             : 
+      86             :     // C = A(I,I) must be empty, except for diagonal entries
+      87         339 :     GRB_TRY (GrB_Matrix_new (&C, GrB_BOOL, isize, isize)) ;
+      88         339 :     GRB_TRY (GrB_Matrix_extract (C, NULL, NULL, A, I, isize, I, isize, NULL)) ;
+      89         339 :     GRB_TRY (GrB_select (C, NULL, NULL, GrB_OFFDIAG, C, 0, NULL)) ;
+      90         339 :     GRB_TRY (GrB_Matrix_nvals (&nvals, C)) ;
+      91         339 :     LG_ASSERT_MSG (nvals == 0, -1, "error!  A(I,I) has an edge!\n") ;
+      92         339 :     GrB_Matrix_free (&C) ;
+      93             : 
+      94             :     // now check if all other nodes are adjacent to the iset
+      95             : 
+      96             :     // e = iset
+      97         339 :     GrB_Vector e = NULL ;
+      98         339 :     GRB_TRY (GrB_Vector_dup (&e, iset)) ;
+      99             : 
+     100             :     // e = e || ignore_node
+     101         339 :     int64_t ignored = 0 ;
+     102         339 :     if (ignore_node != NULL)
+     103             :     {
+     104         160 :         GRB_TRY (GrB_eWiseAdd (e, NULL, NULL, GrB_LOR, e, ignore_node, NULL)) ;
+     105         160 :         GRB_TRY (GrB_reduce (&ignored, NULL, GrB_PLUS_MONOID_INT64,
+     106             :             ignore_node, NULL)) ;
+     107             :     }
+     108             : 
+     109             :     // e = (e || A*iset), using the structural semiring
+     110         339 :     GRB_TRY (GrB_vxm (e, NULL, GrB_LOR, LAGraph_any_one_bool, iset, A, NULL)) ;
+     111             : 
+     112             :     // drop explicit zeros from e
+     113             :     // e<e.replace> = e
+     114         339 :     GRB_TRY (GrB_assign (e, e, NULL, e, GrB_ALL, n, GrB_DESC_R)) ;
+     115             : 
+     116         339 :     GRB_TRY (GrB_Vector_nvals (&nvals, e)) ;
+     117         339 :     GrB_Vector_free (&e) ;
+     118         339 :     LG_ASSERT_MSG (nvals == n, -1, "error! A (I,I is not maximal!\n") ;
+     119             : 
+     120         339 :     LAGraph_Free ((void **) &I, NULL) ;
+     121             : 
+     122         339 :     printf ("maximal independent set OK %.16g of %.16g nodes",
+     123             :         (double) isize, (double) n) ;
+     124         339 :     if (ignored > 0) printf (" (%g nodes ignored)\n", (double) ignored) ;
+     125         339 :     printf ("\n") ;
+     126         339 :     return (GrB_SUCCESS) ;
+     127             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/index-sort-f.html b/experimental/test/index-sort-f.html new file mode 100644 index 0000000000..b5b7191a5c --- /dev/null +++ b/experimental/test/index-sort-f.html @@ -0,0 +1,323 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/testHitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:17021702100.0 %
Date:2024-08-29 20:08:04Functions:4242100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
test_HelloWorld.c +
100.0%
+
100.0 %19 / 19100.0 %1 / 1
LG_check_kcore.c +
100.0%
+
100.0 %65 / 65100.0 %1 / 1
LG_check_mis.c +
100.0%
+
100.0 %38 / 38100.0 %1 / 1
test_Random.c +
100.0%
+
100.0 %31 / 31100.0 %1 / 1
test_Random_Matrix.c +
100.0%
+
100.0 %67 / 67100.0 %1 / 1
test_FastGraphletTransform.c +
100.0%
+
100.0 %44 / 44100.0 %1 / 1
LG_check_ktruss.c +
100.0%
+
100.0 %49 / 49100.0 %1 / 1
LG_check_kcoredecompose.c +
100.0%
+
100.0 %39 / 39100.0 %1 / 1
test_SSaveSet.c +
100.0%
+
100.0 %34 / 34100.0 %1 / 1
test_msf.c +
100.0%
+
100.0 %58 / 58100.0 %2 / 2
test_AllKCore.c +
100.0%
+
100.0 %76 / 76100.0 %2 / 2
test_KTruss.c +
100.0%
+
100.0 %89 / 89100.0 %2 / 2
test_lcc.c +
100.0%
+
100.0 %64 / 64100.0 %2 / 2
test_KCoreDecompose.c +
100.0%
+
100.0 %75 / 75100.0 %2 / 2
test_KCore.c +
100.0%
+
100.0 %70 / 70100.0 %2 / 2
test_SquareClustering.c +
100.0%
+
100.0 %27 / 27100.0 %2 / 2
test_TriangleCentrality.c +
100.0%
+
100.0 %78 / 78100.0 %2 / 2
test_AllKtruss.c +
100.0%
+
100.0 %118 / 118100.0 %2 / 2
test_scc.c +
100.0%
+
100.0 %50 / 50100.0 %2 / 2
test_cdlp.c +
100.0%
+
100.0 %61 / 61100.0 %2 / 2
test_SWrite.c +
100.0%
+
100.0 %142 / 142100.0 %2 / 2
test_MaximalIndependentSet.c +
100.0%
+
100.0 %97 / 97100.0 %3 / 3
test_BF.c +
100.0%
+
100.0 %238 / 238100.0 %3 / 3
test_dnn.c +
100.0%
+
100.0 %73 / 73100.0 %3 / 3
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/index-sort-l.html b/experimental/test/index-sort-l.html new file mode 100644 index 0000000000..80563a94ad --- /dev/null +++ b/experimental/test/index-sort-l.html @@ -0,0 +1,323 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/testHitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:17021702100.0 %
Date:2024-08-29 20:08:04Functions:4242100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
test_HelloWorld.c +
100.0%
+
100.0 %19 / 19100.0 %1 / 1
test_SquareClustering.c +
100.0%
+
100.0 %27 / 27100.0 %2 / 2
test_Random.c +
100.0%
+
100.0 %31 / 31100.0 %1 / 1
test_SSaveSet.c +
100.0%
+
100.0 %34 / 34100.0 %1 / 1
LG_check_mis.c +
100.0%
+
100.0 %38 / 38100.0 %1 / 1
LG_check_kcoredecompose.c +
100.0%
+
100.0 %39 / 39100.0 %1 / 1
test_FastGraphletTransform.c +
100.0%
+
100.0 %44 / 44100.0 %1 / 1
LG_check_ktruss.c +
100.0%
+
100.0 %49 / 49100.0 %1 / 1
test_scc.c +
100.0%
+
100.0 %50 / 50100.0 %2 / 2
test_msf.c +
100.0%
+
100.0 %58 / 58100.0 %2 / 2
test_cdlp.c +
100.0%
+
100.0 %61 / 61100.0 %2 / 2
test_lcc.c +
100.0%
+
100.0 %64 / 64100.0 %2 / 2
LG_check_kcore.c +
100.0%
+
100.0 %65 / 65100.0 %1 / 1
test_Random_Matrix.c +
100.0%
+
100.0 %67 / 67100.0 %1 / 1
test_KCore.c +
100.0%
+
100.0 %70 / 70100.0 %2 / 2
test_dnn.c +
100.0%
+
100.0 %73 / 73100.0 %3 / 3
test_KCoreDecompose.c +
100.0%
+
100.0 %75 / 75100.0 %2 / 2
test_AllKCore.c +
100.0%
+
100.0 %76 / 76100.0 %2 / 2
test_TriangleCentrality.c +
100.0%
+
100.0 %78 / 78100.0 %2 / 2
test_KTruss.c +
100.0%
+
100.0 %89 / 89100.0 %2 / 2
test_MaximalIndependentSet.c +
100.0%
+
100.0 %97 / 97100.0 %3 / 3
test_AllKtruss.c +
100.0%
+
100.0 %118 / 118100.0 %2 / 2
test_SWrite.c +
100.0%
+
100.0 %142 / 142100.0 %2 / 2
test_BF.c +
100.0%
+
100.0 %238 / 238100.0 %3 / 3
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/index.html b/experimental/test/index.html new file mode 100644 index 0000000000..e25968f696 --- /dev/null +++ b/experimental/test/index.html @@ -0,0 +1,323 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/testHitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:17021702100.0 %
Date:2024-08-29 20:08:04Functions:4242100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
LG_check_kcore.c +
100.0%
+
100.0 %65 / 65100.0 %1 / 1
LG_check_kcoredecompose.c +
100.0%
+
100.0 %39 / 39100.0 %1 / 1
LG_check_ktruss.c +
100.0%
+
100.0 %49 / 49100.0 %1 / 1
LG_check_mis.c +
100.0%
+
100.0 %38 / 38100.0 %1 / 1
test_AllKCore.c +
100.0%
+
100.0 %76 / 76100.0 %2 / 2
test_AllKtruss.c +
100.0%
+
100.0 %118 / 118100.0 %2 / 2
test_BF.c +
100.0%
+
100.0 %238 / 238100.0 %3 / 3
test_FastGraphletTransform.c +
100.0%
+
100.0 %44 / 44100.0 %1 / 1
test_HelloWorld.c +
100.0%
+
100.0 %19 / 19100.0 %1 / 1
test_KCore.c +
100.0%
+
100.0 %70 / 70100.0 %2 / 2
test_KCoreDecompose.c +
100.0%
+
100.0 %75 / 75100.0 %2 / 2
test_KTruss.c +
100.0%
+
100.0 %89 / 89100.0 %2 / 2
test_MaximalIndependentSet.c +
100.0%
+
100.0 %97 / 97100.0 %3 / 3
test_Random.c +
100.0%
+
100.0 %31 / 31100.0 %1 / 1
test_Random_Matrix.c +
100.0%
+
100.0 %67 / 67100.0 %1 / 1
test_SSaveSet.c +
100.0%
+
100.0 %34 / 34100.0 %1 / 1
test_SWrite.c +
100.0%
+
100.0 %142 / 142100.0 %2 / 2
test_SquareClustering.c +
100.0%
+
100.0 %27 / 27100.0 %2 / 2
test_TriangleCentrality.c +
100.0%
+
100.0 %78 / 78100.0 %2 / 2
test_cdlp.c +
100.0%
+
100.0 %61 / 61100.0 %2 / 2
test_dnn.c +
100.0%
+
100.0 %73 / 73100.0 %3 / 3
test_lcc.c +
100.0%
+
100.0 %64 / 64100.0 %2 / 2
test_msf.c +
100.0%
+
100.0 %58 / 58100.0 %2 / 2
test_scc.c +
100.0%
+
100.0 %50 / 50100.0 %2 / 2
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_AllKCore.c.func-sort-c.html b/experimental/test/test_AllKCore.c.func-sort-c.html new file mode 100644 index 0000000000..9e12e1e171 --- /dev/null +++ b/experimental/test/test_AllKCore.c.func-sort-c.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_AllKCore.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_AllKCore.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:7676100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_AllKCore1
test_errors1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_AllKCore.c.func.html b/experimental/test/test_AllKCore.c.func.html new file mode 100644 index 0000000000..c239a42ed4 --- /dev/null +++ b/experimental/test/test_AllKCore.c.func.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_AllKCore.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_AllKCore.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:7676100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_AllKCore1
test_errors1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_AllKCore.c.gcov.html b/experimental/test/test_AllKCore.c.gcov.html new file mode 100644 index 0000000000..f695d1392c --- /dev/null +++ b/experimental/test/test_AllKCore.c.gcov.html @@ -0,0 +1,262 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_AllKCore.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_AllKCore.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:7676100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //----------------------------------------------------------------------------
+       2             : // LAGraph/expirimental/test/test_AllKCore.c: test cases for full k-core
+       3             : // decomposition
+       4             : // ----------------------------------------------------------------------------
+       5             : 
+       6             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       7             : // SPDX-License-Identifier: BSD-2-Clause
+       8             : //
+       9             : // For additional details (including references to third party source code and
+      10             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      11             : // Contributors.txt for a full list of contributors. Created, in part, with
+      12             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      13             : // DM22-0790
+      14             : 
+      15             : // Contributed by Pranav Konduri, Texas A&M University
+      16             : 
+      17             : //-----------------------------------------------------------------------------
+      18             : 
+      19             : #include <stdio.h>
+      20             : #include <acutest.h>
+      21             : 
+      22             : #include <LAGraphX.h>
+      23             : #include <LAGraph_test.h>
+      24             : #include "LG_Xtest.h"
+      25             : 
+      26             : char msg [LAGRAPH_MSG_LEN] ;
+      27             : LAGraph_Graph G = NULL ;
+      28             : GrB_Matrix A = NULL ;
+      29             : GrB_Vector c1 = NULL, c2 = NULL;
+      30             : #define LEN 512
+      31             : char filename [LEN+1] ;
+      32             : 
+      33             : typedef struct
+      34             : {
+      35             :     uint64_t kmax ;
+      36             :     const char *name ;
+      37             : }
+      38             : matrix_info ;
+      39             : 
+      40             : const matrix_info files [ ] =
+      41             : {
+      42             :     {     4, "karate.mtx" },
+      43             :     {     6, "west0067.mtx" },
+      44             :     // {   10, "amazon0601.mtx" },
+      45             :     // {   64, "cit-Patents.mtx"},
+      46             :     // {   2208, "hollywood-2009.mtx"},
+      47             :     // {   111, "as-Skitter.mtx"},
+      48             :     { 0, "" },
+      49             : } ;
+      50             : 
+      51             : 
+      52           1 : void test_AllKCore (void)
+      53             : {
+      54           1 :     LAGraph_Init (msg) ;
+      55             : 
+      56           1 :     for (int k = 0 ; ; k++)
+      57           2 :     {
+      58             :         // load the matrix as A
+      59           3 :         const char *aname = files [k].name ;
+      60           3 :         uint64_t kmax = files [k].kmax ;
+      61           3 :         if (strlen (aname) == 0) break;
+      62           2 :         printf ("\n================================== %s: ==================================\n", aname) ;
+      63           2 :         TEST_CASE (aname) ;
+      64           2 :         snprintf (filename, LEN, LG_DATA_DIR "%s", aname) ;
+      65           2 :         FILE *f = fopen (filename, "r") ;
+      66           2 :         TEST_CHECK (f != NULL) ;
+      67           2 :         OK (LAGraph_MMRead (&A, f, msg)) ;
+      68           2 :         TEST_MSG ("Loading of adjacency matrix failed") ;
+      69             : 
+      70             :         // construct an undirected graph G with adjacency matrix A
+      71           2 :         OK (LAGraph_New (&G, &A, LAGraph_ADJACENCY_DIRECTED, msg)) ;
+      72           2 :         TEST_CHECK (A == NULL) ;
+      73             : 
+      74             :         // check if the pattern is symmetric - if it isn't make it.
+      75           2 :         OK (LAGraph_Cached_IsSymmetricStructure (G, msg)) ;
+      76             : 
+      77           2 :         if (G->is_symmetric_structure == LAGraph_FALSE)
+      78             :         {
+      79           1 :             printf("This matrix is not symmetric. \n");
+      80             :             // make the adjacency matrix symmetric
+      81           1 :             OK (LAGraph_Cached_AT (G, msg)) ;
+      82           1 :             OK (GrB_eWiseAdd (G->A, NULL, NULL, GrB_LOR, G->A, G->AT, NULL)) ;
+      83           1 :             G->is_symmetric_structure = true ;
+      84             :             // consider the graph as directed
+      85           1 :             G->kind = LAGraph_ADJACENCY_DIRECTED ;
+      86             :         }
+      87             :         else
+      88             :         {
+      89           1 :             G->kind = LAGraph_ADJACENCY_UNDIRECTED ;
+      90             :         }
+      91             : 
+      92             :         // check for self-edges, and remove them.
+      93           2 :         OK (LAGraph_Cached_NSelfEdges (G, msg)) ;
+      94           2 :         if (G->nself_edges != 0)
+      95             :         {
+      96             :             // remove self-edges
+      97           1 :             printf ("graph has %g self edges\n", (double) G->nself_edges) ;
+      98           1 :             OK (LAGraph_DeleteSelfEdges (G, msg)) ;
+      99           1 :             printf ("now has %g self edges\n", (double) G->nself_edges) ;
+     100           1 :             TEST_CHECK (G->nself_edges == 0) ;
+     101             :         }
+     102             : 
+     103           2 :         int64_t check_kmax = -1; //flag to check kmax in LG_check_kcore
+     104             :         uint64_t km1;
+     105             :         uint64_t km2;
+     106             :         bool ok;
+     107             :         //test the k-core
+     108           2 :         OK(LAGraph_KCore_All(&c1, &km1, G, msg)) ;
+     109             :         // printf ("kmax: %lu km1 %lu\n",  kmax, km1) ;
+     110           2 :         TEST_CHECK(kmax == km1) ;
+     111             : 
+     112           2 :         OK(LG_check_kcore(&c2, &km2, G, check_kmax, msg)) ;
+     113             :         // printf ("kmax: %lu km1 %lu\n",  kmax, km2) ;
+     114             : 
+     115           2 :         TEST_CHECK(kmax == km2) ;
+     116           2 :         TEST_CHECK(km1 == km2) ;
+     117           2 :         OK (LAGraph_Vector_IsEqual (&ok, c1, c2, msg)) ;
+     118           2 :         TEST_CHECK (ok) ;
+     119           2 :         GrB_free (&c1) ;
+     120           2 :         GrB_free (&c2) ;
+     121             : 
+     122           2 :         OK (LAGraph_Delete (&G, msg)) ;
+     123             :     }
+     124             : 
+     125           1 :     LAGraph_Finalize (msg) ;
+     126           1 : }
+     127             : 
+     128             : //------------------------------------------------------------------------------
+     129             : // test_errors
+     130             : //------------------------------------------------------------------------------
+     131             : 
+     132           1 : void test_errors (void)
+     133             : {
+     134           1 :     LAGraph_Init (msg) ;
+     135             : 
+     136           1 :     snprintf (filename, LEN, LG_DATA_DIR "%s", "karate.mtx") ;
+     137           1 :     FILE *f = fopen (filename, "r") ;
+     138           1 :     TEST_CHECK (f != NULL) ;
+     139           1 :     OK (LAGraph_MMRead (&A, f, msg)) ;
+     140           1 :     TEST_MSG ("Loading of adjacency matrix failed") ;
+     141             : 
+     142             :     // construct an undirected graph G with adjacency matrix A
+     143           1 :     OK (LAGraph_New (&G, &A, LAGraph_ADJACENCY_UNDIRECTED, msg)) ;
+     144           1 :     TEST_CHECK (A == NULL) ;
+     145             : 
+     146           1 :     OK (LAGraph_Cached_NSelfEdges (G, msg)) ;
+     147             : 
+     148             :     uint64_t kmax ;
+     149           1 :     GrB_Vector c = NULL ;
+     150             : 
+     151             :     // c is NULL
+     152           1 :     int result = LAGraph_KCore_All (NULL, &kmax, G, msg) ;
+     153           1 :     printf ("\nresult: %d %s\n", result, msg) ;
+     154           1 :     TEST_CHECK (result == GrB_NULL_POINTER) ;
+     155             : 
+     156             :     // G is invalid
+     157           1 :     result = LAGraph_KCore_All (&c, &kmax, NULL, msg) ;
+     158           1 :     printf ("\nresult: %d %s\n", result, msg) ;
+     159           1 :     TEST_CHECK (result == GrB_NULL_POINTER) ;
+     160           1 :     TEST_CHECK (c == NULL) ;
+     161             : 
+     162             :     // G may have self edges
+     163           1 :     G->nself_edges = LAGRAPH_UNKNOWN ;
+     164           1 :     result = LAGraph_KCore_All (&c, &kmax, G, msg) ;
+     165           1 :     printf ("\nresult: %d %s\n", result, msg) ;
+     166           1 :     TEST_CHECK (result == -1004) ;
+     167           1 :     TEST_CHECK (c == NULL) ;
+     168             : 
+     169             :     // G is undirected
+     170           1 :     G->nself_edges = 0 ;
+     171           1 :     G->kind = LAGraph_ADJACENCY_DIRECTED ;
+     172           1 :     G->is_symmetric_structure = LAGraph_FALSE ;
+     173           1 :     result = LAGraph_KCore_All (&c, &kmax, G, msg) ;
+     174           1 :     printf ("\nresult: %d %s\n", result, msg) ;
+     175           1 :     TEST_CHECK (result == -1005) ;
+     176           1 :     TEST_CHECK (c == NULL) ;
+     177             : 
+     178           1 :     OK (LAGraph_Delete (&G, msg)) ;
+     179           1 :     LAGraph_Finalize (msg) ;
+     180           1 : }
+     181             : 
+     182             : TEST_LIST = {
+     183             :     {"AllKCore", test_AllKCore},
+     184             :     {"AllKCore_errors", test_errors},
+     185             :     {NULL, NULL}
+     186             : };
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_AllKtruss.c.func-sort-c.html b/experimental/test/test_AllKtruss.c.func-sort-c.html new file mode 100644 index 0000000000..5c3ed68652 --- /dev/null +++ b/experimental/test/test_AllKtruss.c.func-sort-c.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_AllKtruss.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_AllKtruss.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:118118100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_AllKTruss1
test_allktruss_errors1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_AllKtruss.c.func.html b/experimental/test/test_AllKtruss.c.func.html new file mode 100644 index 0000000000..f60da6a33f --- /dev/null +++ b/experimental/test/test_AllKtruss.c.func.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_AllKtruss.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_AllKtruss.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:118118100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_AllKTruss1
test_allktruss_errors1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_AllKtruss.c.gcov.html b/experimental/test/test_AllKtruss.c.gcov.html new file mode 100644 index 0000000000..3c4e204dfe --- /dev/null +++ b/experimental/test/test_AllKtruss.c.gcov.html @@ -0,0 +1,338 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_AllKtruss.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_AllKtruss.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:118118100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //----------------------------------------------------------------------------
+       2             : // LAGraph/experimental/test/test_AllKtest.c: test cases for all-k-truss
+       3             : // ----------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //-----------------------------------------------------------------------------
+      17             : 
+      18             : #include <stdio.h>
+      19             : #include <acutest.h>
+      20             : 
+      21             : #include "LAGraphX.h"
+      22             : #include "LAGraph_test.h"
+      23             : #include "LG_Xtest.h"
+      24             : 
+      25             : char msg [LAGRAPH_MSG_LEN] ;
+      26             : LAGraph_Graph G = NULL ;
+      27             : GrB_Matrix A = NULL ;
+      28             : GrB_Matrix C1 = NULL ;
+      29             : #define LEN 512
+      30             : char filename [LEN+1] ;
+      31             : 
+      32             : typedef struct
+      33             : {
+      34             :     uint32_t ntriangles ;
+      35             :     const char *name ;
+      36             : }
+      37             : matrix_info ;
+      38             : 
+      39             : const matrix_info files [ ] =
+      40             : {
+      41             :     {     11, "A.mtx" },
+      42             :     {   2016, "jagmesh7.mtx" },
+      43             :     { 342300, "bcsstk13.mtx" },
+      44             :     {     45, "karate.mtx" },
+      45             :     {      6, "ldbc-cdlp-undirected-example.mtx" },
+      46             :     {      4, "ldbc-undirected-example-bool.mtx" },
+      47             :     {      4, "ldbc-undirected-example-unweighted.mtx" },
+      48             :     {      4, "ldbc-undirected-example.mtx" },
+      49             :     {      5, "ldbc-wcc-example.mtx" },
+      50             :     { 0, "" },
+      51             : } ;
+      52             : 
+      53             : //****************************************************************************
+      54           1 : void test_AllKTruss (void)
+      55             : {
+      56           1 :     LAGraph_Init (msg) ;
+      57             : 
+      58           1 :     for (int id = 0 ; ; id++)
+      59           9 :     {
+      60             : 
+      61             :         // load the matrix as A
+      62          10 :         const char *aname = files [id].name ;
+      63          10 :         uint32_t ntriangles = files [id].ntriangles ;
+      64          10 :         if (strlen (aname) == 0) break;
+      65           9 :         printf ("\n================================== %s:\n", aname) ;
+      66           9 :         TEST_CASE (aname) ;
+      67           9 :         snprintf (filename, LEN, LG_DATA_DIR "%s", aname) ;
+      68           9 :         FILE *f = fopen (filename, "r") ;
+      69           9 :         TEST_CHECK (f != NULL) ;
+      70           9 :         OK (LAGraph_MMRead (&A, f, msg)) ;
+      71           9 :         TEST_MSG ("Loading of adjacency matrix failed") ;
+      72           9 :         fclose (f) ;
+      73             : 
+      74             :         // construct an undirected graph G with adjacency matrix A
+      75           9 :         OK (LAGraph_New (&G, &A, LAGraph_ADJACENCY_UNDIRECTED, msg)) ;
+      76           9 :         TEST_CHECK (A == NULL) ;
+      77             : 
+      78             :         // check for self-edges
+      79           9 :         OK (LAGraph_Cached_NSelfEdges (G, msg)) ;
+      80           9 :         if (G->nself_edges != 0)
+      81             :         {
+      82             :             // remove self-edges
+      83           2 :             printf ("graph has %g self edges\n", (double) G->nself_edges) ;
+      84           2 :             OK (LAGraph_DeleteSelfEdges (G, msg)) ;
+      85           2 :             printf ("now has %g self edges\n", (double) G->nself_edges) ;
+      86           2 :             TEST_CHECK (G->nself_edges == 0) ;
+      87             :         }
+      88             : 
+      89             :         // compute each k-truss
+      90           9 :         bool ok = false ;
+      91             :         GrB_Index n ;
+      92             :         int64_t kmax ;
+      93           9 :         OK (GrB_Matrix_nrows (&n, G->A)) ;
+      94             :         GrB_Matrix *Cset ;
+      95             :         int64_t *ntris, *nedges, *nsteps ;
+      96           9 :         OK (LAGraph_Calloc ((void **) &Cset  , n, sizeof (GrB_Matrix), msg)) ;
+      97           9 :         OK (LAGraph_Malloc ((void **) &ntris , n, sizeof (int64_t), msg)) ;
+      98           9 :         OK (LAGraph_Malloc ((void **) &nedges, n, sizeof (int64_t), msg)) ;
+      99           9 :         OK (LAGraph_Malloc ((void **) &nsteps, n, sizeof (int64_t), msg)) ;
+     100             : 
+     101           9 :         OK (LAGraph_AllKTruss (Cset, &kmax, ntris, nedges, nsteps, G, msg)) ;
+     102           9 :         printf ("all k-truss: kmax %g\n", (double) kmax) ;
+     103             : 
+     104             :         // compute each k-truss using LAGraph_KTruss, and compare
+     105          48 :         for (int k = 3 ; k < n ; k++)
+     106             :         {
+     107             :             // printf ("\n%d-truss:\n", k) ;
+     108          48 :             TEST_CHECK (k <= kmax) ;
+     109             :             // compute the k-truss
+     110          48 :             OK (LAGraph_KTruss (&C1, G, k, msg)) ;
+     111             : 
+     112             :             // check the result
+     113             :             GrB_Index nvals ;
+     114          48 :             OK (GrB_Matrix_nvals (&nvals, C1)) ;
+     115          48 :             OK (LAGraph_Matrix_IsEqual (&ok, C1, Cset [k], msg)) ;
+     116          48 :             TEST_CHECK (ok) ;
+     117             : 
+     118             :             // count the triangles in the 3-truss
+     119          48 :             uint32_t nt = 0 ;
+     120          48 :             OK (GrB_reduce (&nt, NULL, GrB_PLUS_MONOID_UINT32, C1, NULL)) ;
+     121          48 :             nt = nt / 6 ;
+     122          48 :             if (k == 3)
+     123             :             {
+     124           9 :                 TEST_CHECK (nt == ntriangles) ;
+     125             :             }
+     126          48 :             TEST_CHECK (nt == ntris [k]) ;
+     127          48 :             TEST_CHECK (nvals == 2 * nedges [k]) ;
+     128          48 :             TEST_CHECK (nsteps [k] >= 0) ;
+     129             : 
+     130             :             // free C1, and break if C1 is empty
+     131          48 :             OK (GrB_free (&C1)) ;
+     132          48 :             if (nvals == 0)
+     133             :             {
+     134           9 :                 TEST_CHECK (k == kmax) ;
+     135           9 :                 break ;
+     136             :             }
+     137             :         }
+     138             : 
+     139             :         // convert to directed with symmetric structure and recompute
+     140           9 :         G->kind = LAGraph_ADJACENCY_DIRECTED ;
+     141           9 :         G->is_symmetric_structure = LAGraph_TRUE ;
+     142             :         int64_t k2 ;
+     143             :         GrB_Matrix *Cset2 ;
+     144             :         int64_t *ntris2, *nedges2, *nsteps2 ;
+     145           9 :         OK (LAGraph_Calloc ((void **) &Cset2  , n, sizeof (GrB_Matrix), msg)) ;
+     146           9 :         OK (LAGraph_Malloc ((void **) &ntris2 , n, sizeof (int64_t), msg)) ;
+     147           9 :         OK (LAGraph_Malloc ((void **) &nedges2, n, sizeof (int64_t), msg)) ;
+     148           9 :         OK (LAGraph_Malloc ((void **) &nsteps2, n, sizeof (int64_t), msg)) ;
+     149             : 
+     150           9 :         OK (LAGraph_AllKTruss (Cset2, &k2, ntris2, nedges2, nsteps2, G, msg)) ;
+     151           9 :         TEST_CHECK (k2 == kmax) ;
+     152          84 :         for (int k = 0 ; k <= kmax ; k++)
+     153             :         {
+     154          75 :             TEST_CHECK (ntris2  [k] == ntris  [k]) ;
+     155          75 :             TEST_CHECK (nedges2 [k] == nedges [k]) ;
+     156          75 :             TEST_CHECK (nsteps2 [k] == nsteps [k]) ;
+     157          75 :             if (k < 3)
+     158             :             {
+     159          27 :                 TEST_CHECK (Cset [k] == NULL) ;
+     160          27 :                 TEST_CHECK (Cset2 [k] == NULL) ;
+     161             :             }
+     162             :             else
+     163             :             {
+     164          48 :                 OK (LAGraph_Matrix_IsEqual (&ok, Cset [k], Cset2 [k], msg)) ;
+     165             :             }
+     166             : //          if (!ok)
+     167             : //          {
+     168             : //              GxB_print (Cset [k], 2) ;
+     169             : //              GxB_print (Cset2 [k], 2) ;
+     170             : //          }
+     171          75 :             TEST_CHECK (ok) ;
+     172          75 :             OK (GrB_free (&(Cset [k]))) ;
+     173          75 :             OK (GrB_free (&(Cset2 [k]))) ;
+     174             :         }
+     175             : 
+     176           9 :         LAGraph_Free ((void **) &Cset, NULL) ;
+     177           9 :         LAGraph_Free ((void **) &ntris, NULL) ;
+     178           9 :         LAGraph_Free ((void **) &nedges, NULL) ;
+     179           9 :         LAGraph_Free ((void **) &nsteps, NULL) ;
+     180             : 
+     181           9 :         LAGraph_Free ((void **) &Cset2, NULL) ;
+     182           9 :         LAGraph_Free ((void **) &ntris2, NULL) ;
+     183           9 :         LAGraph_Free ((void **) &nedges2, NULL) ;
+     184           9 :         LAGraph_Free ((void **) &nsteps2, NULL) ;
+     185             : 
+     186           9 :         OK (LAGraph_Delete (&G, msg)) ;
+     187             :     }
+     188             : 
+     189           1 :     LAGraph_Finalize (msg) ;
+     190           1 : }
+     191             : 
+     192             : //------------------------------------------------------------------------------
+     193             : // test_AllKTruss_errors
+     194             : //------------------------------------------------------------------------------
+     195             : 
+     196           1 : void test_allktruss_errors (void)
+     197             : {
+     198           1 :     LAGraph_Init (msg) ;
+     199             : 
+     200           1 :     snprintf (filename, LEN, LG_DATA_DIR "%s", "karate.mtx") ;
+     201           1 :     FILE *f = fopen (filename, "r") ;
+     202           1 :     TEST_CHECK (f != NULL) ;
+     203           1 :     OK (LAGraph_MMRead (&A, f, msg)) ;
+     204           1 :     TEST_MSG ("Loading of adjacency matrix failed") ;
+     205           1 :     fclose (f) ;
+     206             : 
+     207             :     // construct an undirected graph G with adjacency matrix A
+     208           1 :     OK (LAGraph_New (&G, &A, LAGraph_ADJACENCY_UNDIRECTED, msg)) ;
+     209           1 :     TEST_CHECK (A == NULL) ;
+     210             : 
+     211           1 :     OK (LAGraph_Cached_NSelfEdges (G, msg)) ;
+     212             : 
+     213             :     GrB_Index n ;
+     214             :     int64_t kmax ;
+     215           1 :     OK (GrB_Matrix_nrows (&n, G->A)) ;
+     216             :     int64_t *ntris, *nedges, *nsteps ;
+     217             :     GrB_Matrix *Cset ;
+     218           1 :     OK (LAGraph_Calloc ((void **) &Cset  , n, sizeof (GrB_Matrix), msg)) ;
+     219           1 :     OK (LAGraph_Malloc ((void **) &ntris , n, sizeof (int64_t), msg)) ;
+     220           1 :     OK (LAGraph_Malloc ((void **) &nedges, n, sizeof (int64_t), msg)) ;
+     221           1 :     OK (LAGraph_Malloc ((void **) &nsteps, n, sizeof (int64_t), msg)) ;
+     222             : 
+     223             :     // kmax is NULL
+     224           1 :     int result = LAGraph_AllKTruss (Cset, NULL, ntris, nedges, nsteps, G, msg) ;
+     225           1 :     printf ("\nresult: %d %s\n", result, msg) ;
+     226           1 :     TEST_CHECK (result == GrB_NULL_POINTER) ;
+     227             : 
+     228             :     // G is invalid
+     229           1 :     result = LAGraph_AllKTruss (Cset, &kmax, ntris, nedges, nsteps, NULL, msg) ;
+     230           1 :     printf ("\nresult: %d %s\n", result, msg) ;
+     231           1 :     TEST_CHECK (result == GrB_NULL_POINTER) ;
+     232             : 
+     233             :     // G may have self edges
+     234           1 :     G->nself_edges = LAGRAPH_UNKNOWN ;
+     235           1 :     result = LAGraph_AllKTruss (Cset, &kmax, ntris, nedges, nsteps, G, msg) ;
+     236           1 :     printf ("\nresult: %d %s\n", result, msg) ;
+     237           1 :     TEST_CHECK (result == -1004) ;
+     238             : 
+     239             :     // G is undirected
+     240           1 :     G->nself_edges = 0 ;
+     241           1 :     G->kind = LAGraph_ADJACENCY_DIRECTED ;
+     242           1 :     G->is_symmetric_structure = LAGraph_FALSE ;
+     243           1 :     result = LAGraph_AllKTruss (Cset, &kmax, ntris, nedges, nsteps, G, msg) ;
+     244           1 :     printf ("\nresult: %d %s\n", result, msg) ;
+     245           1 :     TEST_CHECK (result == -1005) ;
+     246             : 
+     247           1 :     LAGraph_Free ((void **) &Cset, NULL) ;
+     248           1 :     LAGraph_Free ((void **) &ntris, NULL) ;
+     249           1 :     LAGraph_Free ((void **) &nedges, NULL) ;
+     250           1 :     LAGraph_Free ((void **) &nsteps, NULL) ;
+     251             : 
+     252           1 :     OK (LAGraph_Delete (&G, msg)) ;
+     253           1 :     LAGraph_Finalize (msg) ;
+     254           1 : }
+     255             : 
+     256             : //****************************************************************************
+     257             : 
+     258             : TEST_LIST = {
+     259             :     {"allktruss", test_AllKTruss},
+     260             :     {"allktruss_errors", test_allktruss_errors},
+     261             :     {NULL, NULL}
+     262             : };
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_BF.c.func-sort-c.html b/experimental/test/test_BF.c.func-sort-c.html new file mode 100644 index 0000000000..9089d630ab --- /dev/null +++ b/experimental/test/test_BF.c.func-sort-c.html @@ -0,0 +1,84 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_BF.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_BF.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:238238100.0 %
Date:2024-08-29 20:08:04Functions:33100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
setup1
teardown1
test_BF1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_BF.c.func.html b/experimental/test/test_BF.c.func.html new file mode 100644 index 0000000000..1555327c7e --- /dev/null +++ b/experimental/test/test_BF.c.func.html @@ -0,0 +1,84 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_BF.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_BF.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:238238100.0 %
Date:2024-08-29 20:08:04Functions:33100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
setup1
teardown1
test_BF1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_BF.c.gcov.html b/experimental/test/test_BF.c.gcov.html new file mode 100644 index 0000000000..c28dd3cff1 --- /dev/null +++ b/experimental/test/test_BF.c.gcov.html @@ -0,0 +1,592 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_BF.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_BF.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:238238100.0 %
Date:2024-08-29 20:08:04Functions:33100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph/experimental/test/test_BF
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Jinhao Chen and Tim Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include <stdio.h>
+      19             : #include <acutest.h>
+      20             : #include <LAGraphX.h>
+      21             : #include <LAGraph_test.h>
+      22             : #include <LG_Xtest.h>
+      23             : 
+      24             : //------------------------------------------------------------------------------
+      25             : // globals
+      26             : //------------------------------------------------------------------------------
+      27             : 
+      28             : #define LEN 512
+      29             : char filename [LEN+1] ;
+      30             : char msg [LAGRAPH_MSG_LEN] ;
+      31             : 
+      32             : //------------------------------------------------------------------------------
+      33             : // test cases
+      34             : //------------------------------------------------------------------------------
+      35             : 
+      36             : typedef struct
+      37             : {
+      38             :     bool has_negative_cycle ;
+      39             :     bool has_integer_weights ;
+      40             :     const char *name ;
+      41             : }
+      42             : matrix_info ;
+      43             : 
+      44             : const matrix_info files [ ] =
+      45             : {
+      46             :     0, 1, "karate.mtx",
+      47             :     1, 0, "west0067.mtx",
+      48             :     1, 1, "matrix_int8.mtx",
+      49             :     0, 0, ""
+      50             : } ;
+      51             : 
+      52             : //------------------------------------------------------------------------------
+      53             : // setup: start a test
+      54             : //------------------------------------------------------------------------------
+      55             : 
+      56           1 : void setup (void)
+      57             : {
+      58           1 :     OK (LAGraph_Init (msg)) ;
+      59           1 :     OK (LAGraph_Random_Init (msg)) ;
+      60           1 : }
+      61             : 
+      62             : //------------------------------------------------------------------------------
+      63             : // teardown: finalize a test
+      64             : //------------------------------------------------------------------------------
+      65             : 
+      66           1 : void teardown (void)
+      67             : {
+      68           1 :     OK (LAGraph_Random_Finalize (msg)) ;
+      69           1 :     OK (LAGraph_Finalize (msg)) ;
+      70           1 : }
+      71             : 
+      72           1 : void test_BF (void)
+      73             : {
+      74             : 
+      75             :     GrB_Info info ;
+      76           1 :     setup ( ) ;
+      77             : 
+      78           1 :     for (int k = 0 ; ; k++)
+      79           3 :     {
+      80           4 :         GrB_Matrix A = NULL, AT = NULL, A_orig = NULL ;
+      81           4 :         GrB_Index *I = NULL, *J = NULL ; // for col/row indices of entries in A
+      82           4 :         double *W = NULL, *d = NULL ;
+      83           4 :         int64_t *pi = NULL, *pi10 = NULL ;
+      84           4 :         int32_t *W_int32 = NULL, *d10 = NULL ;
+      85           4 :         GrB_Vector d1 = NULL, d2 = NULL, d3 = NULL, d4 = NULL, d5 = NULL,
+      86           4 :             d5a = NULL, d6 = NULL, d7 = NULL, d8 = NULL, d9 = NULL, h1 = NULL,
+      87           4 :             h2 = NULL, h5 = NULL, h5a = NULL, h6 = NULL, pi1 = NULL, pi2 = NULL,
+      88           4 :             pi5 = NULL, pi5a = NULL, pi6 = NULL ;
+      89             : 
+      90             :         //----------------------------------------------------------------------
+      91             :         // read in a matrix from a file
+      92             :         //----------------------------------------------------------------------
+      93             : 
+      94             :         // load the matrix as A_orig
+      95           4 :         const char *aname = files [k].name ;
+      96           4 :         if (strlen (aname) == 0) break;
+      97           3 :         TEST_CASE (aname) ;
+      98           3 :         snprintf (filename, LEN, LG_DATA_DIR "%s", aname) ;
+      99           3 :         FILE *f = fopen (filename, "r") ;
+     100           3 :         TEST_CHECK (f != NULL) ;
+     101           3 :         OK (LAGraph_MMRead (&A_orig, f, msg)) ;
+     102           3 :         OK (fclose (f)) ;
+     103           3 :         TEST_MSG ("Loading of valued matrix failed") ;
+     104           3 :         printf ("\nMatrix: %s\n", aname) ;
+     105           3 :         OK (LAGraph_Matrix_Print (A_orig, LAGraph_SHORT, stdout, NULL)) ;
+     106             : 
+     107           3 :         bool has_negative_cycle  = files [k].has_negative_cycle ;
+     108           3 :         bool has_integer_weights = files [k].has_integer_weights ;
+     109           3 :         int ktrials = (has_negative_cycle) ? 2 : 1 ;
+     110             : 
+     111             :         //----------------------------------------------------------------------
+     112             :         // get the size of the problem
+     113             :         //----------------------------------------------------------------------
+     114             : 
+     115             :         GrB_Index nvals ;
+     116           3 :         GrB_Matrix_nvals (&nvals, A_orig) ;
+     117             :         GrB_Index nrows, ncols ;
+     118           3 :         OK (GrB_Matrix_nrows (&nrows, A_orig)) ;
+     119           3 :         OK (GrB_Matrix_ncols (&ncols, A_orig)) ;
+     120           3 :         GrB_Index n = nrows ;
+     121           3 :         OK (LAGraph_Malloc ((void **) &I, nvals, sizeof (GrB_Index), msg)) ;
+     122           3 :         OK (LAGraph_Malloc ((void **) &J, nvals, sizeof (GrB_Index), msg)) ;
+     123           3 :         OK (LAGraph_Malloc ((void **) &W, nvals, sizeof (double), msg)) ;
+     124           3 :         OK (LAGraph_Malloc ((void **) &W_int32, nvals, sizeof (int32_t), msg)) ;
+     125             : 
+     126           3 :         OK (GrB_Matrix_extractTuples_FP64 (I, J, W, &nvals, A_orig)) ;
+     127           3 :         if (has_integer_weights)
+     128             :         {
+     129           2 :             OK (GrB_Matrix_extractTuples_INT32 (I, J, W_int32, &nvals,
+     130             :                 A_orig)) ;
+     131             :         }
+     132             : 
+     133             :         //----------------------------------------------------------------------
+     134             :         // copy the matrix and set its diagonal to 0
+     135             :         //----------------------------------------------------------------------
+     136             : 
+     137           3 :         OK (GrB_Matrix_dup (&A, A_orig)) ;
+     138         111 :         for (GrB_Index i = 0; i < n; i++)
+     139             :         {
+     140         108 :             OK (GrB_Matrix_setElement_FP64 (A, 0, i, i)) ;
+     141             :         }
+     142             : 
+     143             :         //----------------------------------------------------------------------
+     144             :         // AT = A'
+     145             :         //----------------------------------------------------------------------
+     146             : 
+     147           3 :         double tt = LAGraph_WallClockTime ( ) ;
+     148           3 :         OK (GrB_Matrix_free (&AT)) ;
+     149           3 :         OK (GrB_Matrix_new (&AT, GrB_FP64, ncols, nrows)) ;
+     150           3 :         OK (GrB_transpose (AT, NULL, NULL, A, NULL)) ;
+     151           3 :         double transpose_time = LAGraph_WallClockTime ( ) - tt ;
+     152           3 :         fprintf (stderr, "transpose     time: %g\n", transpose_time) ;
+     153             : 
+     154             :         //----------------------------------------------------------------------
+     155             :         // get the source node
+     156             :         //----------------------------------------------------------------------
+     157             : 
+     158           3 :         GrB_Index s = 0 ;
+     159           3 :         fprintf (stderr, "\n==========input graph: nodes: %g edges: %g "
+     160             :             "source node: %g\n", (double) n, (double) nvals, (double) s) ;
+     161             : 
+     162             :         //----------------------------------------------------------------------
+     163             :         // run 1 or 2 trials (2 negative weight cycles)
+     164             :         //----------------------------------------------------------------------
+     165             : 
+     166           8 :         for (int kk = 1 ; kk <= ktrials ; kk++)
+     167             :         {
+     168           5 :             int valid = (has_negative_cycle) ? GrB_NO_VALUE : GrB_SUCCESS ;
+     169             : 
+     170             :             //------------------------------------------------------------------
+     171             :             // run LAGraph_BF_full1 before setting the diagonal to 0
+     172             :             //------------------------------------------------------------------
+     173             : 
+     174           5 :             int ntrials = 1 ;   // increase this to 10, 100, whatever, for more
+     175             :                                 // accurate timing
+     176             :             // start the timer
+     177           5 :             double t5 = LAGraph_WallClockTime ( ) ;
+     178             :             int result ;
+     179             : 
+     180          10 :             for (int trial = 0 ; trial < ntrials ; trial++)
+     181             :             {
+     182           5 :                 GrB_free (&d5) ;
+     183           5 :                 GrB_free (&pi5) ;
+     184           5 :                 GrB_free (&h5) ;
+     185           5 :                 result = (LAGraph_BF_full1 (&d5, &pi5, &h5, A_orig, s)) ;
+     186           5 :                 printf ("result: %d\n", result) ;
+     187           5 :                 TEST_CHECK (result == valid) ;
+     188             :             }
+     189             : 
+     190             :             // stop the timer
+     191           5 :             t5 = LAGraph_WallClockTime ( ) - t5 ;
+     192           5 :             t5 = t5 / ntrials;
+     193           5 :             fprintf (stderr, "BF_full1      time: %12.6e (sec), rate:"
+     194           5 :                 " %g (1e6 edges/sec)\n", t5, 1e-6*((double) nvals) / t5) ;
+     195             : 
+     196             :             //------------------------------------------------------------------
+     197             :             // run LAGraph_BF_full1a before setting the diagonal to 0
+     198             :             //------------------------------------------------------------------
+     199             : 
+     200             :             // start the timer
+     201           5 :             double t5a = LAGraph_WallClockTime ( ) ;
+     202             : 
+     203          10 :             for (int trial = 0 ; trial < ntrials ; trial++)
+     204             :             {
+     205           5 :                 GrB_free (&d5a) ;
+     206           5 :                 GrB_free (&pi5a) ;
+     207           5 :                 GrB_free (&h5a) ;
+     208           5 :                 result = (LAGraph_BF_full1a (&d5a, &pi5a, &h5a, A_orig, s)) ;
+     209           5 :                 TEST_CHECK (result == valid) ;
+     210             :             }
+     211             : 
+     212             :             // stop the timer
+     213           5 :             t5a = LAGraph_WallClockTime ( ) - t5a ;
+     214           5 :             t5a = t5a / ntrials;
+     215           5 :             fprintf (stderr, "BF_full1a     time: %12.6e (sec), rate:"
+     216           5 :                 " %g (1e6 edges/sec)\n", t5a, 1e-6*((double) nvals) / t5a) ;
+     217             : 
+     218             :             //------------------------------------------------------------------
+     219             :             // run LAGraph_BF_full2 before setting the diagonal to 0
+     220             :             //------------------------------------------------------------------
+     221             : 
+     222             :             // start the timer
+     223           5 :             double t6 = LAGraph_WallClockTime ( ) ;
+     224             : 
+     225          10 :             for (int trial = 0 ; trial < ntrials ; trial++)
+     226             :             {
+     227           5 :                 GrB_free (&d6) ;
+     228           5 :                 GrB_free (&pi6) ;
+     229           5 :                 GrB_free (&h6) ;
+     230           5 :                 result = LAGraph_BF_full2 (&d6, &pi6, &h6, A_orig, s) ;
+     231           5 :                 TEST_CHECK (result == valid) ;
+     232             :             }
+     233             : 
+     234             :             // stop the timer
+     235           5 :             t6 = LAGraph_WallClockTime ( ) - t6 ;
+     236           5 :             t6 = t6 / ntrials;
+     237           5 :             fprintf (stderr, "BF_full2      time: %12.6e (sec), rate:"
+     238           5 :                 " %g (1e6 edges/sec)\n", t6, 1e-6*((double) nvals) / t6) ;
+     239             : 
+     240             :             //------------------------------------------------------------------
+     241             :             // run the LAGraph_BF_full on node s
+     242             :             //------------------------------------------------------------------
+     243             : 
+     244             :             // start the timer
+     245           5 :             double t1 = LAGraph_WallClockTime ( ) ;
+     246             : 
+     247          10 :             for (int trial = 0 ; trial < ntrials ; trial++)
+     248             :             {
+     249           5 :                 GrB_free (&d1) ;
+     250           5 :                 GrB_free (&pi1) ;
+     251           5 :                 GrB_free (&h1) ;
+     252           5 :                 result = LAGraph_BF_full (&d1, &pi1, &h1, A, s) ;
+     253           5 :                 printf ("result %d\n", result) ;
+     254           5 :                 TEST_CHECK (result == valid) ;
+     255             :             }
+     256             : 
+     257             :             // stop the timer
+     258           5 :             t1 = LAGraph_WallClockTime ( ) - t1 ;
+     259           5 :             t1 = t1 / ntrials;
+     260           5 :             fprintf (stderr, "BF_full       time: %12.6e (sec), rate:"
+     261           5 :                 " %g (1e6 edges/sec)\n", t1, 1e-6*((double) nvals) / t1) ;
+     262           5 :             fprintf (stderr, "t(BF_full1) / t(BF_full):      %g\n", t5/t1) ;
+     263             : 
+     264             :             //------------------------------------------------------------------
+     265             :             // run the BF on node s with LAGraph_BF_basic
+     266             :             //------------------------------------------------------------------
+     267             : 
+     268             :             // start the timer
+     269           5 :             double t2 = LAGraph_WallClockTime ( ) ;
+     270             : 
+     271          10 :             for (int trial = 0 ; trial < ntrials ; trial++)
+     272             :             {
+     273           5 :                 GrB_free (&d3) ;
+     274           5 :                 result = LAGraph_BF_basic (&d3, A, s) ;
+     275           5 :                 TEST_CHECK (result == valid) ;
+     276             :             }
+     277             : 
+     278             :             // stop the timer
+     279           5 :             t2 = LAGraph_WallClockTime ( ) - t2 ;
+     280           5 :             t2 = t2 / ntrials;
+     281           5 :             fprintf (stderr, "BF_basic      time: %12.6e (sec), rate:"
+     282           5 :                 " %g (1e6 edges/sec)\n", t2, 1e-6*((double) nvals) / t2) ;
+     283           5 :             fprintf (stderr, "speedup of BF_basic:       %g\n", t1/t2) ;
+     284             : 
+     285             :             //------------------------------------------------------------------
+     286             :             // run the BF on node s with LAGraph_pure_c
+     287             :             //------------------------------------------------------------------
+     288             : 
+     289             :             // start the timer
+     290           5 :             double t3 = LAGraph_WallClockTime ( ) ;
+     291             : 
+     292          10 :             for (int trial = 0 ; trial < ntrials ; trial++)
+     293             :             {
+     294           5 :                 LAGraph_Free ((void **) &d, NULL) ;
+     295           5 :                 LAGraph_Free ((void **) &pi, NULL) ;
+     296           5 :                 result = LAGraph_BF_pure_c_double (&d, &pi, s, n, nvals,
+     297             :                     (const int64_t *) I, (const int64_t *) J, W) ;
+     298           5 :                 TEST_CHECK (result == valid) ;
+     299             :             }
+     300             : 
+     301             :             // stop the timer
+     302           5 :             t3 = LAGraph_WallClockTime ( ) - t3 ;
+     303           5 :             t3 = t3 / ntrials;
+     304           5 :             fprintf (stderr, "BF_pure_c_double  : %12.6e (sec), rate:"
+     305           5 :                 " %g (1e6 edges/sec)\n", t3, 1e-6*((double) nvals) / t3) ;
+     306           5 :             fprintf (stderr, "speedup of BF_pure_c:      %g\n", t1/t3) ;
+     307             : 
+     308           5 :             if (has_integer_weights)
+     309             :             {
+     310           3 :                 printf ("pure_c integer:\n") ;
+     311           3 :                 LAGraph_Free ((void **) &d10, NULL) ;
+     312           3 :                 LAGraph_Free ((void **) &pi10, NULL) ;
+     313           3 :                 result = LAGraph_BF_pure_c (&d10, &pi10, s, n, nvals,
+     314             :                     (const int64_t *) I, (const int64_t *) J, W_int32) ;
+     315           3 :                 LAGraph_Free ((void **) &pi10, NULL) ;
+     316           3 :                 TEST_CHECK (result == valid) ;
+     317             :             }
+     318             : 
+     319             :             //------------------------------------------------------------------
+     320             :             // run the LAGraph_BF_full_mxv on node s
+     321             :             //------------------------------------------------------------------
+     322             : 
+     323             :             // start the timer
+     324           5 :             double t4 = LAGraph_WallClockTime ( ) ;
+     325             : 
+     326          10 :             for (int trial = 0 ; trial < ntrials ; trial++)
+     327             :             {
+     328           5 :                 GrB_free (&d2) ;
+     329           5 :                 GrB_free (&pi2) ;
+     330           5 :                 GrB_free (&h2) ;
+     331           5 :                 result = LAGraph_BF_full_mxv (&d2, &pi2, &h2, AT, s) ;
+     332           5 :                 TEST_CHECK (result == valid) ;
+     333             :             }
+     334             : 
+     335             :             // stop the timer
+     336           5 :             t4 = LAGraph_WallClockTime ( ) - t4 ;
+     337           5 :             t4 = t4 / ntrials;
+     338           5 :             fprintf (stderr, "BF_full_mxv   time: %12.6e (sec), rate:"
+     339           5 :                 " %g (1e6 edges/sec)\n", t4, 1e-6*((double) nvals) / t4) ;
+     340           5 :             fprintf (stderr, "speedup of BF_full_mxv:    %g\n", t1/t4) ;
+     341             : 
+     342             :             //------------------------------------------------------------------
+     343             :             // run the BF on node s with LAGraph_BF_basic_mxv
+     344             :             //------------------------------------------------------------------
+     345             : 
+     346             :             // start the timer
+     347           5 :             double t7 = LAGraph_WallClockTime ( ) ;
+     348             : 
+     349          10 :             for (int trial = 0 ; trial < ntrials ; trial++)
+     350             :             {
+     351           5 :                 GrB_free (&d4) ;
+     352           5 :                 result = LAGraph_BF_basic_mxv (&d4, AT, s) ;
+     353           5 :                 TEST_CHECK (result == valid) ;
+     354             :             }
+     355             : 
+     356             :             // stop the timer
+     357           5 :             t7 = LAGraph_WallClockTime ( ) - t7 ;
+     358           5 :             t7 = t7 / ntrials;
+     359           5 :             fprintf (stderr, "BF_basic_mxv  time: %12.6e (sec), rate:"
+     360           5 :                 " %g (1e6 edges/sec)\n", t7, 1e-6*((double) nvals) / t7) ;
+     361           5 :             fprintf (stderr, "speedup of BF_basic_mxv:   %g\n", t1/t7) ;
+     362             : 
+     363             :             //------------------------------------------------------------------
+     364             :             // run the BF on node s with LAGraph_BF_basic_pushpull
+     365             :             //------------------------------------------------------------------
+     366             : 
+     367           5 :             GrB_free (&d7) ;
+     368           5 :             result = (LAGraph_BF_basic_pushpull (&d7, A, AT, s)) ;
+     369           5 :             TEST_CHECK (result == valid) ;
+     370             : 
+     371           5 :             GrB_free (&d8) ;
+     372           5 :             result = (LAGraph_BF_basic_pushpull (&d8, NULL, AT, s)) ;
+     373           5 :             TEST_CHECK (result == valid) ;
+     374             : 
+     375           5 :             GrB_free (&d9) ;
+     376           5 :             result = (LAGraph_BF_basic_pushpull (&d9, A, NULL, s)) ;
+     377           5 :             TEST_CHECK (result == valid) ;
+     378             : 
+     379             :             //------------------------------------------------------------------
+     380             :             // check results
+     381             :             //------------------------------------------------------------------
+     382             : 
+     383           5 :             bool isequal = false ;
+     384             : 
+     385           5 :             if (!has_negative_cycle)
+     386             :             {
+     387           3 :                 TEST_CHECK (d != NULL && d1 != NULL) ;
+     388             : 
+     389         111 :                 for (int64_t i = 0 ; i < n ; i++)
+     390             :                 {
+     391         108 :                     double di = INFINITY ;
+     392         108 :                     int64_t pii = 0;
+     393         108 :                     OK (GrB_Vector_extractElement (&di, d1, i)) ;
+     394         108 :                     TEST_CHECK (di == d[i]) ;
+     395             : 
+     396             :                     // since d5 is a dense vector filled with infinity, we have
+     397             :                     // to compare it against d seperaterly
+     398         108 :                     OK (GrB_Vector_extractElement (&di, d5, i)) ;
+     399         108 :                     TEST_CHECK (di == d[i]) ;
+     400             : 
+     401             :                     // since d5a is a dense vector filled with infinity, we
+     402             :                     // have to compare it against d seperaterly
+     403         108 :                     OK (GrB_Vector_extractElement (&di, d5a, i)) ;
+     404         108 :                     TEST_CHECK (di == d[i]) ;
+     405             :                     /*
+     406             :                     OK (GrB_Vector_extractElement (&pii, pi1, i)) ;
+     407             :                     TEST_CHECK (pii == pi[i]+1) ;
+     408             :                     */
+     409             :                 }
+     410             : 
+     411           3 :                 if (has_integer_weights)
+     412             :                 {
+     413             :                     // compare d and d10
+     414          43 :                     for (int64_t i = 0 ; i < n ; i++)
+     415             :                     {
+     416          41 :                         double d10i = (double) d10 [i] ;
+     417          41 :                         double di = (isinf (d [i])) ? INT32_MAX : d [i] ;
+     418          41 :                         TEST_CHECK (d10i == di) ;
+     419             :                     }
+     420             :                 }
+     421             : 
+     422           3 :                 OK (LAGraph_Vector_IsEqual (&isequal, d1, d3, NULL)) ;
+     423           3 :                 TEST_CHECK (isequal) ;
+     424             : 
+     425           3 :                 OK (LAGraph_Vector_IsEqual (&isequal, d1, d4, NULL)) ;
+     426           3 :                 TEST_CHECK (isequal) ;
+     427             : 
+     428           3 :                 OK (LAGraph_Vector_IsEqual (&isequal, d1, d2, NULL)) ;
+     429           3 :                 TEST_CHECK (isequal) ;
+     430             : 
+     431           3 :                 OK (LAGraph_Vector_IsEqual (&isequal, d1, d6, NULL)) ;
+     432           3 :                 TEST_CHECK (isequal) ;
+     433             : 
+     434             :                 /*
+     435             :                 OK (LAGraph_Vector_IsEqual (&isequal, pi1, pi2, NULL)) ;
+     436             :                 TEST_CHECK (isequal) ;
+     437             :                 */
+     438             : 
+     439           3 :                 OK (LAGraph_Vector_IsEqual (&isequal, d1, d7, NULL)) ;
+     440           3 :                 TEST_CHECK (isequal) ;
+     441             : 
+     442           3 :                 OK (LAGraph_Vector_IsEqual (&isequal, d1, d8, NULL)) ;
+     443           3 :                 TEST_CHECK (isequal) ;
+     444             : 
+     445           3 :                 OK (LAGraph_Vector_IsEqual (&isequal, d1, d9, NULL)) ;
+     446           3 :                 TEST_CHECK (isequal) ;
+     447             :             }
+     448             : 
+     449             :             //------------------------------------------------------------------
+     450             :             // ensure the matrix has all positive weights for next trial
+     451             :             //------------------------------------------------------------------
+     452             : 
+     453           5 :             if (has_negative_cycle)
+     454             :             {
+     455           2 :                 printf ("\n-------------------------- A = abs (A)\n") ;
+     456           2 :                 OK (GrB_apply (A,  NULL, NULL, GrB_ABS_FP64, A,  NULL)) ;
+     457           2 :                 OK (GrB_apply (AT, NULL, NULL, GrB_ABS_FP64, AT, NULL)) ;
+     458           2 :                 OK (GrB_apply (A_orig, NULL, NULL, GrB_ABS_FP64, A_orig, NULL));
+     459           2 :                 OK (GrB_Matrix_extractTuples_FP64  (I, J, W, &nvals, A_orig)) ;
+     460           2 :                 if (has_integer_weights)
+     461             :                 {
+     462           1 :                     OK (GrB_Matrix_extractTuples_INT32 (I, J, W_int32, &nvals,
+     463             :                         A_orig)) ;
+     464             :                 }
+     465           2 :                 has_negative_cycle = false ;
+     466             :             }
+     467             :         }
+     468             : 
+     469             :         //----------------------------------------------------------------------
+     470             :         // free all workspace and finish
+     471             :         //----------------------------------------------------------------------
+     472             : 
+     473           3 :         GrB_free (&A) ;
+     474           3 :         GrB_free (&A_orig) ;
+     475           3 :         GrB_free (&AT) ;
+     476           3 :         LAGraph_Free ((void **) &I, NULL) ;
+     477           3 :         LAGraph_Free ((void **) &J, NULL) ;
+     478           3 :         LAGraph_Free ((void **) &W, NULL) ;
+     479           3 :         LAGraph_Free ((void **) &W_int32, NULL) ;
+     480           3 :         LAGraph_Free ((void **) &d, NULL) ;
+     481           3 :         LAGraph_Free ((void **) &pi, NULL) ;
+     482           3 :         GrB_free (&d1) ;
+     483           3 :         GrB_free (&pi1) ;
+     484           3 :         GrB_free (&h1) ;
+     485           3 :         GrB_free (&d2) ;
+     486           3 :         GrB_free (&pi2) ;
+     487           3 :         GrB_free (&h2) ;
+     488           3 :         GrB_free (&d3) ;
+     489           3 :         GrB_free (&d4) ;
+     490           3 :         GrB_free (&d5) ;
+     491           3 :         GrB_free (&pi5) ;
+     492           3 :         GrB_free (&h5) ;
+     493           3 :         GrB_free (&d5a) ;
+     494           3 :         GrB_free (&pi5a) ;
+     495           3 :         GrB_free (&h5a) ;
+     496           3 :         GrB_free (&d6) ;
+     497           3 :         GrB_free (&d7) ;
+     498           3 :         GrB_free (&d8) ;
+     499           3 :         GrB_free (&d9) ;
+     500           3 :         GrB_free (&pi6) ;
+     501           3 :         GrB_free (&h6) ;
+     502           3 :         LAGraph_Free ((void **) &d10, NULL) ;
+     503             :     }
+     504             : 
+     505           1 :     teardown ( ) ;
+     506           1 : }
+     507             : 
+     508             : //------------------------------------------------------------------------------
+     509             : // TEST_LIST: list of tasks for this entire test
+     510             : //------------------------------------------------------------------------------
+     511             : 
+     512             : TEST_LIST =
+     513             : {
+     514             :     { "test_BF", test_BF },
+     515             :     { NULL, NULL }
+     516             : } ;
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_FastGraphletTransform.c.func-sort-c.html b/experimental/test/test_FastGraphletTransform.c.func-sort-c.html new file mode 100644 index 0000000000..24b6e24b0b --- /dev/null +++ b/experimental/test/test_FastGraphletTransform.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_FastGraphletTransform.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_FastGraphletTransform.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:4444100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_FastGraphletTransform1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_FastGraphletTransform.c.func.html b/experimental/test/test_FastGraphletTransform.c.func.html new file mode 100644 index 0000000000..e4e9a6e11f --- /dev/null +++ b/experimental/test/test_FastGraphletTransform.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_FastGraphletTransform.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_FastGraphletTransform.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:4444100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_FastGraphletTransform1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_FastGraphletTransform.c.gcov.html b/experimental/test/test_FastGraphletTransform.c.gcov.html new file mode 100644 index 0000000000..db298ce7eb --- /dev/null +++ b/experimental/test/test_FastGraphletTransform.c.gcov.html @@ -0,0 +1,251 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_FastGraphletTransform.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_FastGraphletTransform.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:4444100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //----------------------------------------------------------------------------
+       2             : // LAGraph/src/test/test_TriangleCount.cpp: test cases for triangle
+       3             : 
+       4             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       5             : // SPDX-License-Identifier: BSD-2-Clause
+       6             : //
+       7             : // For additional details (including references to third party source code and
+       8             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+       9             : // Contributors.txt for a full list of contributors. Created, in part, with
+      10             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      11             : // DM22-0790
+      12             : 
+      13             : //-----------------------------------------------------------------------------
+      14             : 
+      15             : #include <stdio.h>
+      16             : #include <acutest.h>
+      17             : #include <LAGraphX.h>
+      18             : #include <LAGraph_test.h>
+      19             : #include <LG_Xtest.h>
+      20             : #include <LG_test.h>
+      21             : 
+      22             : #include <graph_zachary_karate.h>
+      23             : 
+      24             : char msg[LAGRAPH_MSG_LEN];
+      25             : LAGraph_Graph G = NULL;
+      26             : 
+      27             : #define LEN 512
+      28             : char filename [LEN+1] ;
+      29             : 
+      30             : int64_t karate_graphlet_counts [ ] =
+      31             : {
+      32             :     1,16,17,102,18,81,197,13,352,6,34,171,10,2,30,7,
+      33             :     1,9,19,24,12,73,56,33,32,8,80,27,6,2,18,7,
+      34             :     1,10,34,34,11,72,179,84,54,17,75,51,20,6,8,7,
+      35             :     1,6,20,5,10,49,11,56,1,5,81,5,0,4,7,7,
+      36             :     1,3,16,1,2,17,1,64,0,15,25,0,1,2,1,0,
+      37             :     1,4,15,3,3,15,14,64,0,14,25,2,1,2,2,0,
+      38             :     1,4,15,3,3,15,14,64,0,14,25,2,1,2,2,0,
+      39             :     1,4,25,0,6,37,0,87,0,5,53,0,0,11,0,4,
+      40             :     1,5,44,5,5,31,74,208,0,23,58,6,10,12,3,1,
+      41             :     1,2,25,1,0,40,15,130,0,26,0,0,5,0,0,0,
+      42             :     1,3,16,1,2,17,1,64,0,15,25,0,1,2,1,0,
+      43             :     1,1,15,0,0,17,0,87,0,18,0,0,0,0,0,0,
+      44             :     1,2,18,0,1,27,0,79,0,18,10,0,0,4,0,0,
+      45             :     1,5,41,4,6,27,69,192,0,20,53,6,10,11,0,4,
+      46             :     1,2,25,0,1,34,0,142,0,8,7,0,0,9,0,0,
+      47             :     1,2,25,0,1,34,0,142,0,8,7,0,0,9,0,0,
+      48             :     1,2,4,0,1,28,0,0,0,2,2,0,0,1,0,0,
+      49             :     1,2,21,0,1,27,0,96,0,16,9,0,0,6,0,0,
+      50             :     1,2,25,0,1,34,0,142,0,8,7,0,0,9,0,0,
+      51             :     1,3,37,2,1,31,43,201,0,31,9,1,5,6,0,0,
+      52             :     1,2,25,0,1,34,0,142,0,8,7,0,0,9,0,0,
+      53             :     1,2,21,0,1,27,0,96,0,16,9,0,0,6,0,0,
+      54             :     1,2,25,0,1,34,0,142,0,8,7,0,0,9,0,0,
+      55             :     1,5,27,6,4,36,39,111,2,5,43,5,4,9,2,1,
+      56             :     1,3,8,2,1,67,7,6,0,3,5,1,2,0,0,0,
+      57             :     1,3,9,2,1,62,7,6,0,6,5,1,3,0,0,0,
+      58             :     1,2,17,0,1,29,0,93,0,13,13,0,0,2,0,0,
+      59             :     1,4,29,5,1,47,53,120,2,25,14,2,8,2,0,0,
+      60             :     1,3,28,2,1,59,23,122,0,25,17,1,7,1,0,0,
+      61             :     1,4,24,2,4,34,11,111,0,4,43,1,0,9,2,1,
+      62             :     1,4,33,3,3,56,39,138,0,18,32,3,5,9,0,1,
+      63             :     1,6,42,12,3,34,149,216,9,25,23,10,10,9,1,0,
+      64             :     1,12,23,53,13,56,150,40,139,10,75,34,10,4,45,2,
+      65             :     1,17,18,121,15,81,210,3,507,9,26,123,25,1,48,2
+      66             : };
+      67             : 
+      68             : int64_t A_graphlet_counts [ ] =
+      69             : {
+      70             :     1,3,8,1,2,1,0,2,0,5,2,0,3,4,1,0,
+      71             :     1,5,5,5,5,0,0,0,1,0,0,4,5,5,4,1,
+      72             :     1,5,3,3,7,0,1,0,0,0,5,1,1,2,7,2,
+      73             :     1,5,3,3,7,0,1,0,0,0,5,1,1,2,7,2,
+      74             :     1,3,8,1,2,1,0,2,0,5,2,0,3,4,1,0,
+      75             :     1,4,6,1,5,0,0,2,0,0,6,0,2,4,2,2,
+      76             :     1,5,5,5,5,0,0,0,1,0,0,4,5,5,4,1
+      77             : };
+      78             : 
+      79           1 : void test_FastGraphletTransform(void)
+      80             : {
+      81           1 :     LAGraph_Init (msg) ;
+      82             :     #if LAGRAPH_SUITESPARSE
+      83             : 
+      84           1 :     GrB_Matrix A = NULL, F_net = NULL ;
+      85             :     GrB_Index n ;
+      86           1 :     bool ok = 1 ;
+      87             : 
+      88             :     //--------------------------------------------------------------------------
+      89             :     // karate
+      90             :     //--------------------------------------------------------------------------
+      91             : 
+      92             :     {
+      93             :         // create the karate graph
+      94           1 :         snprintf (filename, LEN, LG_DATA_DIR "%s", "karate.mtx") ;
+      95           1 :         FILE *f = fopen (filename, "r") ;
+      96           1 :         TEST_CHECK (f != NULL) ;
+      97           1 :         OK (LAGraph_MMRead (&A, f, msg)) ;
+      98           1 :         OK (fclose (f)) ;
+      99           1 :         OK (LAGraph_New (&G, &A, LAGraph_ADJACENCY_UNDIRECTED, msg)) ;
+     100           1 :         TEST_CHECK (A == NULL) ;    // A has been moved into G->A
+     101             : 
+     102           1 :         OK (LAGraph_DeleteSelfEdges (G, msg)) ;
+     103             : 
+     104             :         // get the net frequency matrix
+     105           1 :         OK (LAGraph_FastGraphletTransform (&F_net, G, true, msg)) ;
+     106           1 :         printf ("# Matrix: %s\n", "karate.mtx") ;
+     107             : 
+     108           1 :         OK (GrB_Matrix_nrows (&n, G->A)) ;
+     109             : 
+     110             :         // check that each element matches fglt result
+     111          35 :         for (int i = 0 ; i < n ; i++) {
+     112         578 :             for (int j = 0 ; j < 16 ; j++) {
+     113             :                 int64_t x;
+     114         544 :                 if (GrB_Matrix_extractElement (&x, F_net, j, i) == GrB_NO_VALUE)
+     115           2 :                     x = 0 ;
+     116         544 :                 ok &= (x == karate_graphlet_counts [16 * i + j]) ;
+     117             :             }
+     118             :         }
+     119             : 
+     120           1 :         TEST_CHECK (ok) ;
+     121             : 
+     122           1 :         OK (GrB_free (&F_net)) ;
+     123           1 :         OK (LAGraph_Delete (&G, msg)) ;
+     124             :     }
+     125             : 
+     126             :     //--------------------------------------------------------------------------
+     127             :     // A
+     128             :     //--------------------------------------------------------------------------
+     129             : 
+     130             :     {
+     131             :         // create the A graph
+     132           1 :         snprintf (filename, LEN, LG_DATA_DIR "%s", "A.mtx") ;
+     133           1 :         FILE *f = fopen (filename, "r") ;
+     134           1 :         TEST_CHECK (f != NULL) ;
+     135           1 :         OK (LAGraph_MMRead (&A, f, msg)) ;
+     136           1 :         OK (fclose (f)) ;
+     137           1 :         OK (LAGraph_New (&G, &A, LAGraph_ADJACENCY_UNDIRECTED, msg)) ;
+     138           1 :         TEST_CHECK (A == NULL) ;    // A has been moved into G->A
+     139             : 
+     140           1 :         OK (LAGraph_DeleteSelfEdges (G, msg)) ;
+     141             : 
+     142             :         // get the net frequency matrix
+     143           1 :         OK (LAGraph_FastGraphletTransform (&F_net, G, true, msg)) ;
+     144           1 :         printf ("# Matrix: %s\n", "A.mtx") ;
+     145             : 
+     146           1 :         OK (GrB_Matrix_nrows (&n, G->A)) ;
+     147             : 
+     148             :         // check that each element matches fglt result
+     149           8 :         for (int i = 0 ; i < n ; i++) {
+     150         119 :             for (int j = 0 ; j < 16 ; j++) {
+     151         112 :                 int64_t x = 0 ;
+     152         112 :                 OK (GrB_Matrix_extractElement (&x, F_net, j, i)) ;
+     153         112 :                 ok &= (x == A_graphlet_counts [16 * i + j]) ;
+     154             :             }
+     155             :         }
+     156             : 
+     157           1 :         TEST_CHECK (ok) ;
+     158             : 
+     159           1 :         OK (GrB_free (&F_net)) ;
+     160           1 :         OK (LAGraph_Delete (&G, msg)) ;
+     161             :     }
+     162             : 
+     163             :     //--------------------------------------------------------------------------
+     164             : 
+     165             :     #endif
+     166           1 :     LAGraph_Finalize (msg) ;
+     167           1 : }
+     168             : 
+     169             : 
+     170             : //****************************************************************************
+     171             : //****************************************************************************
+     172             : TEST_LIST = {
+     173             :     {"FastGraphletTransform", test_FastGraphletTransform},
+     174             :     {NULL, NULL}
+     175             : };
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_HelloWorld.c.func-sort-c.html b/experimental/test/test_HelloWorld.c.func-sort-c.html new file mode 100644 index 0000000000..37c3da0af4 --- /dev/null +++ b/experimental/test/test_HelloWorld.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_HelloWorld.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_HelloWorld.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1919100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_HelloWorld1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_HelloWorld.c.func.html b/experimental/test/test_HelloWorld.c.func.html new file mode 100644 index 0000000000..ab5e39ac82 --- /dev/null +++ b/experimental/test/test_HelloWorld.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_HelloWorld.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_HelloWorld.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1919100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_HelloWorld1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_HelloWorld.c.gcov.html b/experimental/test/test_HelloWorld.c.gcov.html new file mode 100644 index 0000000000..69d3b17d42 --- /dev/null +++ b/experimental/test/test_HelloWorld.c.gcov.html @@ -0,0 +1,161 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_HelloWorld.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_HelloWorld.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1919100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //----------------------------------------------------------------------------
+       2             : // LAGraph/src/test/test_HelloWorld.c: test cases for LAGraph_HelloWorld
+       3             : //----------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : //-----------------------------------------------------------------------------
+      15             : 
+      16             : // This is a very simple "hello world" example of a test program for an
+      17             : // algorithm in the experimental/algorithm folder.
+      18             : 
+      19             : #include <stdio.h>
+      20             : #include <acutest.h>
+      21             : #include <LAGraphX.h>
+      22             : #include <LAGraph_test.h>
+      23             : #include <LG_Xtest.h>
+      24             : #include <LG_test.h>
+      25             : 
+      26             : char msg [LAGRAPH_MSG_LEN] ;
+      27             : LAGraph_Graph G = NULL ;
+      28             : 
+      29             : #define LEN 512
+      30             : char filename [LEN+1] ;
+      31             : 
+      32           1 : void test_HelloWorld (void)
+      33             : {
+      34             : 
+      35             :     //--------------------------------------------------------------------------
+      36             :     // start LAGraph
+      37             :     //--------------------------------------------------------------------------
+      38             : 
+      39           1 :     LAGraph_Init (msg) ;
+      40           1 :     GrB_Matrix Y = NULL, A = NULL ;
+      41             : 
+      42             :     //--------------------------------------------------------------------------
+      43             :     // test with the west0067 matrix
+      44             :     //--------------------------------------------------------------------------
+      45             : 
+      46             :     // create the graph
+      47           1 :     snprintf (filename, LEN, LG_DATA_DIR "%s", "west0067.mtx") ;
+      48           1 :     FILE *f = fopen (filename, "r") ;
+      49           1 :     TEST_CHECK (f != NULL) ;
+      50           1 :     OK (LAGraph_MMRead (&A, f, msg)) ;
+      51           1 :     OK (fclose (f)) ;
+      52           1 :     OK (LAGraph_New (&G, &A, LAGraph_ADJACENCY_DIRECTED, msg)) ;
+      53           1 :     TEST_CHECK (A == NULL) ;    // A has been moved into G->A
+      54             : 
+      55             :     // test the algorithm
+      56           1 :     OK (LAGraph_HelloWorld (&Y, G, msg)) ;
+      57             : 
+      58             :     // print the result
+      59           1 :     printf ("\nOutput of LAGraph_HelloWorld:\n") ;
+      60           1 :     OK (LAGraph_Matrix_Print (Y, LAGraph_COMPLETE, stdout, msg)) ;
+      61             : 
+      62             :     // check the result (ensure Y is equal to G->A)
+      63             :     bool ok ;
+      64           1 :     OK (LAGraph_Matrix_IsEqual (&ok, Y, G->A, msg)) ;
+      65           1 :     TEST_CHECK (ok) ;
+      66             : 
+      67             :     //--------------------------------------------------------------------------
+      68             :     // free everything and finalize LAGraph
+      69             :     //--------------------------------------------------------------------------
+      70             : 
+      71           1 :     OK (GrB_free (&Y)) ;
+      72           1 :     OK (LAGraph_Delete (&G, msg)) ;
+      73             : 
+      74           1 :     LAGraph_Finalize (msg) ;
+      75           1 : }
+      76             : 
+      77             : //----------------------------------------------------------------------------
+      78             : // the make program is created by acutest, and it runs a list of tests:
+      79             : //----------------------------------------------------------------------------
+      80             : 
+      81             : TEST_LIST =
+      82             : {
+      83             :     {"HelloWorld", test_HelloWorld},    // just one test in this example
+      84             :     {NULL, NULL}
+      85             : } ;
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_KCore.c.func-sort-c.html b/experimental/test/test_KCore.c.func-sort-c.html new file mode 100644 index 0000000000..351d73a045 --- /dev/null +++ b/experimental/test/test_KCore.c.func-sort-c.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_KCore.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_KCore.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:7070100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_KCore1
test_errors1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_KCore.c.func.html b/experimental/test/test_KCore.c.func.html new file mode 100644 index 0000000000..3d892d7cb0 --- /dev/null +++ b/experimental/test/test_KCore.c.func.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_KCore.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_KCore.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:7070100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_KCore1
test_errors1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_KCore.c.gcov.html b/experimental/test/test_KCore.c.gcov.html new file mode 100644 index 0000000000..14b459a20b --- /dev/null +++ b/experimental/test/test_KCore.c.gcov.html @@ -0,0 +1,249 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_KCore.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_KCore.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:7070100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //----------------------------------------------------------------------------
+       2             : // LAGraph/expirimental/test/test_KCore.c: test cases for single k-core
+       3             : // ----------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Pranav Konduri, Texas A&M University
+      15             : 
+      16             : //-----------------------------------------------------------------------------
+      17             : 
+      18             : #include <stdio.h>
+      19             : #include <acutest.h>
+      20             : 
+      21             : #include <LAGraphX.h>
+      22             : #include <LAGraph_test.h>
+      23             : #include "LG_Xtest.h"
+      24             : 
+      25             : char msg [LAGRAPH_MSG_LEN] ;
+      26             : LAGraph_Graph G = NULL ;
+      27             : GrB_Matrix A = NULL ;
+      28             : GrB_Vector c1 = NULL, c2 = NULL;
+      29             : #define LEN 512
+      30             : char filename [LEN+1] ;
+      31             : 
+      32             : typedef struct
+      33             : {
+      34             :     const char *name ;
+      35             : }
+      36             : matrix_info ;
+      37             : 
+      38             : const matrix_info files [ ] =
+      39             : {
+      40             :     {"karate.mtx" },
+      41             :     {"west0067.mtx" },
+      42             :     // {"amazon0601.mtx" },
+      43             :     // {"cit-Patents.mtx"},
+      44             :     // {"hollywood-2009.mtx"},
+      45             :     // {"as-Skitter.mtx"},
+      46             :     {""},
+      47             : } ;
+      48             : 
+      49             : 
+      50           1 : void test_KCore (void)
+      51             : {
+      52           1 :     LAGraph_Init (msg) ;
+      53             : 
+      54           1 :     for (int k = 0 ; ; k++)
+      55           2 :     {
+      56             :         // load the matrix as A
+      57           3 :         const char *aname = files [k].name ;
+      58           3 :         if (strlen (aname) == 0) break;
+      59           2 :         printf ("\n================================== %s: ==================================\n", aname) ;
+      60           2 :         TEST_CASE (aname) ;
+      61           2 :         snprintf (filename, LEN, LG_DATA_DIR "%s", aname) ;
+      62           2 :         FILE *f = fopen (filename, "r") ;
+      63           2 :         TEST_CHECK (f != NULL) ;
+      64           2 :         OK (LAGraph_MMRead (&A, f, msg)) ;
+      65           2 :         TEST_MSG ("Loading of adjacency matrix failed") ;
+      66             : 
+      67             :         // construct an undirected graph G with adjacency matrix A
+      68           2 :         OK (LAGraph_New (&G, &A, LAGraph_ADJACENCY_DIRECTED, msg)) ;
+      69           2 :         TEST_CHECK (A == NULL) ;
+      70             : 
+      71             :         // check if the pattern is symmetric - if it isn't make it.
+      72           2 :         OK (LAGraph_Cached_IsSymmetricStructure (G, msg)) ;
+      73             : 
+      74           2 :         if (G->is_symmetric_structure == LAGraph_FALSE)
+      75             :         {
+      76           1 :             printf("This matrix is not symmetric. \n");
+      77             :             // make the adjacency matrix symmetric
+      78           1 :             OK (LAGraph_Cached_AT (G, msg)) ;
+      79           1 :             OK (GrB_eWiseAdd (G->A, NULL, NULL, GrB_LOR, G->A, G->AT, NULL)) ;
+      80           1 :             G->is_symmetric_structure = true ;
+      81             :             // consider the graph as directed
+      82           1 :             G->kind = LAGraph_ADJACENCY_DIRECTED ;
+      83             :         }
+      84             :         else
+      85             :         {
+      86           1 :             G->kind = LAGraph_ADJACENCY_UNDIRECTED ;
+      87             :         }
+      88             : 
+      89             :         // check for self-edges, and remove them.
+      90           2 :         OK (LAGraph_Cached_NSelfEdges (G, msg)) ;
+      91           2 :         if (G->nself_edges != 0)
+      92             :         {
+      93             :             // remove self-edges
+      94           1 :             printf ("graph has %g self edges\n", (double) G->nself_edges) ;
+      95           1 :             OK (LAGraph_DeleteSelfEdges (G, msg)) ;
+      96           1 :             printf ("now has %g self edges\n", (double) G->nself_edges) ;
+      97           1 :             TEST_CHECK (G->nself_edges == 0) ;
+      98             :         }
+      99             : 
+     100             :         uint64_t kmax;
+     101             :         bool ok;
+     102             :         //test the k-core
+     103           2 :         OK(LAGraph_KCore(&c1, G, 2, msg)) ;
+     104           2 :         OK(LG_check_kcore(&c2, &kmax, G, 2, msg)) ;
+     105             : 
+     106           2 :         OK (LAGraph_Vector_IsEqual (&ok, c1, c2, msg)) ;
+     107           2 :         TEST_CHECK (ok) ;
+     108             : 
+     109           2 :         OK (LAGraph_Delete (&G, msg)) ;
+     110             :     }
+     111             : 
+     112           1 :     LAGraph_Finalize (msg) ;
+     113           1 : }
+     114             : 
+     115             : //------------------------------------------------------------------------------
+     116             : // test_errors
+     117             : //------------------------------------------------------------------------------
+     118             : 
+     119           1 : void test_errors (void)
+     120             : {
+     121           1 :     LAGraph_Init (msg) ;
+     122             : 
+     123           1 :     snprintf (filename, LEN, LG_DATA_DIR "%s", "karate.mtx") ;
+     124           1 :     FILE *f = fopen (filename, "r") ;
+     125           1 :     TEST_CHECK (f != NULL) ;
+     126           1 :     OK (LAGraph_MMRead (&A, f, msg)) ;
+     127           1 :     TEST_MSG ("Loading of adjacency matrix failed") ;
+     128             : 
+     129             :     // construct an undirected graph G with adjacency matrix A
+     130           1 :     OK (LAGraph_New (&G, &A, LAGraph_ADJACENCY_UNDIRECTED, msg)) ;
+     131           1 :     TEST_CHECK (A == NULL) ;
+     132             : 
+     133           1 :     OK (LAGraph_Cached_NSelfEdges (G, msg)) ;
+     134             : 
+     135           1 :     uint64_t k = 1; //some test k
+     136           1 :     GrB_Vector c = NULL ;
+     137             : 
+     138             :     // c is NULL
+     139           1 :     int result = LAGraph_KCore (NULL, G, k, msg) ;
+     140           1 :     printf ("\nresult: %d %s\n", result, msg) ;
+     141           1 :     TEST_CHECK (result == GrB_NULL_POINTER) ;
+     142             : 
+     143             :     // G is invalid
+     144           1 :     result = LAGraph_KCore (&c, NULL, k, msg) ;
+     145           1 :     printf ("\nresult: %d %s\n", result, msg) ;
+     146           1 :     TEST_CHECK (result == GrB_NULL_POINTER) ;
+     147           1 :     TEST_CHECK (c == NULL) ;
+     148             : 
+     149             :     // G may have self edges
+     150           1 :     G->nself_edges = LAGRAPH_UNKNOWN ;
+     151           1 :     result = LAGraph_KCore (&c, G, k, msg) ;
+     152           1 :     printf ("\nresult: %d %s\n", result, msg) ;
+     153           1 :     TEST_CHECK (result == -1004) ;
+     154           1 :     TEST_CHECK (c == NULL) ;
+     155             : 
+     156             :     // G is undirected
+     157           1 :     G->nself_edges = 0 ;
+     158           1 :     G->kind = LAGraph_ADJACENCY_DIRECTED ;
+     159           1 :     G->is_symmetric_structure = LAGraph_FALSE ;
+     160           1 :     result = LAGraph_KCore (&c, G, k, msg) ;
+     161           1 :     printf ("\nresult: %d %s\n", result, msg) ;
+     162           1 :     TEST_CHECK (result == -1005) ;
+     163           1 :     TEST_CHECK (c == NULL) ;
+     164             : 
+     165           1 :     OK (LAGraph_Delete (&G, msg)) ;
+     166           1 :     LAGraph_Finalize (msg) ;
+     167           1 : }
+     168             : 
+     169             : TEST_LIST = {
+     170             :     {"KCore", test_KCore},
+     171             :     {"KCore_errors", test_errors},
+     172             :     {NULL, NULL}
+     173             : };
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_KCoreDecompose.c.func-sort-c.html b/experimental/test/test_KCoreDecompose.c.func-sort-c.html new file mode 100644 index 0000000000..3dcb340263 --- /dev/null +++ b/experimental/test/test_KCoreDecompose.c.func-sort-c.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_KCoreDecompose.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_KCoreDecompose.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:7575100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_KCoreDecompose1
test_errors1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_KCoreDecompose.c.func.html b/experimental/test/test_KCoreDecompose.c.func.html new file mode 100644 index 0000000000..b6ca5b8857 --- /dev/null +++ b/experimental/test/test_KCoreDecompose.c.func.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_KCoreDecompose.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_KCoreDecompose.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:7575100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_KCoreDecompose1
test_errors1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_KCoreDecompose.c.gcov.html b/experimental/test/test_KCoreDecompose.c.gcov.html new file mode 100644 index 0000000000..816b1fe7c9 --- /dev/null +++ b/experimental/test/test_KCoreDecompose.c.gcov.html @@ -0,0 +1,267 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_KCoreDecompose.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_KCoreDecompose.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:7575100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //----------------------------------------------------------------------------
+       2             : // LAGraph/expirimental/test/test_KCoreDecompose.c: test cases for k-core
+       3             : // decomposition
+       4             : // ----------------------------------------------------------------------------
+       5             : 
+       6             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       7             : // SPDX-License-Identifier: BSD-2-Clause
+       8             : //
+       9             : // For additional details (including references to third party source code and
+      10             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      11             : // Contributors.txt for a full list of contributors. Created, in part, with
+      12             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      13             : // DM22-0790
+      14             : 
+      15             : // Contributed by Pranav Konduri, Texas A&M University
+      16             : 
+      17             : //-----------------------------------------------------------------------------
+      18             : 
+      19             : #include <stdio.h>
+      20             : #include <acutest.h>
+      21             : 
+      22             : #include <LAGraphX.h>
+      23             : #include <LAGraph_test.h>
+      24             : #include "LG_Xtest.h"
+      25             : 
+      26             : char msg [LAGRAPH_MSG_LEN] ;
+      27             : LAGraph_Graph G = NULL ;
+      28             : GrB_Matrix A = NULL, D1 = NULL, D2 = NULL;
+      29             : GrB_Vector c = NULL;
+      30             : #define LEN 512
+      31             : char filename [LEN+1] ;
+      32             : 
+      33             : typedef struct
+      34             : {
+      35             :     uint64_t kval ;
+      36             :     const char *name ;
+      37             : }
+      38             : matrix_info ;
+      39             : 
+      40             : const matrix_info files [ ] =
+      41             : {
+      42             :     {     4, "karate.mtx" },
+      43             :     {     6, "west0067.mtx" },
+      44             :     // {   10, "amazon0601.mtx" },
+      45             :     // {   64, "cit-Patents.mtx"},
+      46             :     // {   2208, "hollywood-2009.mtx"},
+      47             :     // {   111, "as-Skitter.mtx"},
+      48             :     { 0, "" },
+      49             : } ;
+      50             : 
+      51             : 
+      52           1 : void test_KCoreDecompose (void)
+      53             : {
+      54           1 :     LAGraph_Init (msg) ;
+      55             :     #if LAGRAPH_SUITESPARSE
+      56             : 
+      57           1 :     for (int k = 0 ; ; k++)
+      58           2 :     {
+      59             :         // load the matrix as A
+      60           3 :         const char *aname = files [k].name ;
+      61           3 :         uint64_t kval = files [k].kval ;
+      62           3 :         if (strlen (aname) == 0) break;
+      63           2 :         TEST_CASE (aname) ;
+      64           2 :         snprintf (filename, LEN, LG_DATA_DIR "%s", aname) ;
+      65           2 :         FILE *f = fopen (filename, "r") ;
+      66           2 :         TEST_CHECK (f != NULL) ;
+      67           2 :         OK (LAGraph_MMRead (&A, f, msg)) ;
+      68           2 :         TEST_MSG ("Loading of adjacency matrix failed") ;
+      69             : 
+      70             :         // construct an undirected graph G with adjacency matrix A
+      71           2 :         OK (LAGraph_New (&G, &A, LAGraph_ADJACENCY_DIRECTED, msg)) ;
+      72           2 :         TEST_CHECK (A == NULL) ;
+      73             : 
+      74             :         // check if the pattern is symmetric - if it isn't make it.
+      75           2 :         OK (LAGraph_Cached_IsSymmetricStructure (G, msg)) ;
+      76             : 
+      77           2 :         if (G->is_symmetric_structure == LAGraph_FALSE)
+      78             :         {
+      79           1 :             printf("This matrix is not symmetric. \n");
+      80             :             // make the adjacency matrix symmetric
+      81           1 :             OK (LAGraph_Cached_AT (G, msg)) ;
+      82           1 :             OK (GrB_eWiseAdd (G->A, NULL, NULL, GrB_LOR, G->A, G->AT, NULL)) ;
+      83           1 :             G->is_symmetric_structure = true ;
+      84             :             // consider the graph as directed
+      85           1 :             G->kind = LAGraph_ADJACENCY_DIRECTED ;
+      86             :         }
+      87             :         else
+      88             :         {
+      89           1 :             G->kind = LAGraph_ADJACENCY_UNDIRECTED ;
+      90             :         }
+      91             : 
+      92             :         // check for self-edges, and remove them.
+      93           2 :         OK (LAGraph_Cached_NSelfEdges (G, msg)) ;
+      94           2 :         if (G->nself_edges != 0)
+      95             :         {
+      96             :             // remove self-edges
+      97           1 :             printf ("graph has %g self edges\n", (double) G->nself_edges) ;
+      98           1 :             OK (LAGraph_DeleteSelfEdges (G, msg)) ;
+      99           1 :             printf ("now has %g self edges\n", (double) G->nself_edges) ;
+     100           1 :             TEST_CHECK (G->nself_edges == 0) ;
+     101             :         }
+     102             : 
+     103             :         bool ok;
+     104             :         //get the kcore at the designated k-value
+     105           2 :         LAGraph_KCore(&c, G, kval, msg) ;
+     106             : 
+     107             :         //decompose the k-core from vector c into D1
+     108           2 :         LAGraph_KCore_Decompose(&D1, G, c, kval, msg);
+     109             : 
+     110             :         //decompose the k-core from vector c into D2
+     111           2 :         LG_check_kcore_decompose(&D2, G, c, kval, msg);
+     112             : 
+     113             :         //check equality
+     114           2 :         OK (LAGraph_Matrix_IsEqual (&ok, D1, D2, msg)) ;
+     115           2 :         TEST_CHECK(ok);
+     116             : 
+     117           2 :         OK (LAGraph_Delete (&G, msg)) ;
+     118             :     }
+     119             : 
+     120             :     #endif
+     121           1 :     LAGraph_Finalize (msg) ;
+     122           1 : }
+     123             : 
+     124             : //------------------------------------------------------------------------------
+     125             : // test_errors
+     126             : //------------------------------------------------------------------------------
+     127             : 
+     128           1 : void test_errors (void)
+     129             : {
+     130           1 :     LAGraph_Init (msg) ;
+     131             :     #if LAGRAPH_SUITESPARSE
+     132             : 
+     133           1 :     snprintf (filename, LEN, LG_DATA_DIR "%s", "karate.mtx") ;
+     134           1 :     FILE *f = fopen (filename, "r") ;
+     135           1 :     TEST_CHECK (f != NULL) ;
+     136           1 :     OK (LAGraph_MMRead (&A, f, msg)) ;
+     137           1 :     TEST_MSG ("Loading of adjacency matrix failed") ;
+     138             : 
+     139             :     // construct an undirected graph G with adjacency matrix A
+     140           1 :     OK (LAGraph_New (&G, &A, LAGraph_ADJACENCY_UNDIRECTED, msg)) ;
+     141           1 :     TEST_CHECK (A == NULL) ;
+     142             : 
+     143           1 :     OK (LAGraph_Cached_NSelfEdges (G, msg)) ;
+     144             : 
+     145           1 :     uint64_t kval = 2 ;
+     146           1 :     GrB_Vector c = NULL ;
+     147             : 
+     148             :     // c is NULL
+     149           1 :     int result = LAGraph_KCore_Decompose (&D1, G, NULL, kval, msg) ;
+     150           1 :     printf ("\nresult: %d %s\n", result, msg) ;
+     151           1 :     TEST_CHECK (result == GrB_NULL_POINTER) ;
+     152             : 
+     153             :     // G is invalid
+     154           1 :     result = LAGraph_KCore_Decompose (&D1, NULL, c, kval, msg) ;
+     155           1 :     printf ("\nresult: %d %s\n", result, msg) ;
+     156           1 :     TEST_CHECK (result == GrB_NULL_POINTER) ;
+     157           1 :     TEST_CHECK (c == NULL) ;
+     158             : 
+     159             :     // G may have self edges
+     160           1 :     G->nself_edges = LAGRAPH_UNKNOWN ;
+     161           1 :     result = LAGraph_KCore_Decompose(&D1, G, c, kval, msg);
+     162           1 :     printf ("\nresult: %d %s\n", result, msg) ;
+     163           1 :     TEST_CHECK (result == -1004) ;
+     164           1 :     TEST_CHECK (c == NULL) ;
+     165             : 
+     166             :     // G is directed
+     167           1 :     G->nself_edges = 0 ;
+     168           1 :     G->kind = LAGraph_ADJACENCY_DIRECTED ;
+     169           1 :     G->is_symmetric_structure = LAGraph_FALSE ;
+     170           1 :     result = LAGraph_KCore_Decompose(&D1, G, c, kval, msg);
+     171           1 :     printf ("\nresult: %d %s\n", result, msg) ;
+     172           1 :     TEST_CHECK (result == -1005) ;
+     173           1 :     TEST_CHECK (c == NULL) ;
+     174             : 
+     175           1 :     result = LG_check_kcore_decompose(&D1, G, c, kval, msg);
+     176           1 :     printf ("\nresult: %d %s\n", result, msg) ;
+     177           1 :     TEST_CHECK (result == -1005) ;
+     178           1 :     TEST_CHECK (c == NULL) ;
+     179             : 
+     180           1 :     OK (LAGraph_Delete (&G, msg)) ;
+     181             :     #endif
+     182           1 :     LAGraph_Finalize (msg) ;
+     183           1 : }
+     184             : 
+     185             : TEST_LIST = {
+     186             :     #if LAGRAPH_SUITESPARSE
+     187             :     {"KCoreDecompose", test_KCoreDecompose},
+     188             :     {"KCoreDecompose_errors", test_errors},
+     189             :     #endif
+     190             :     {NULL, NULL}
+     191             : };
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_KTruss.c.func-sort-c.html b/experimental/test/test_KTruss.c.func-sort-c.html new file mode 100644 index 0000000000..bf175e94c5 --- /dev/null +++ b/experimental/test/test_KTruss.c.func-sort-c.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_KTruss.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_KTruss.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:8989100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_ktruss1
test_ktruss_errors1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_KTruss.c.func.html b/experimental/test/test_KTruss.c.func.html new file mode 100644 index 0000000000..bf279c0431 --- /dev/null +++ b/experimental/test/test_KTruss.c.func.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_KTruss.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_KTruss.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:8989100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_ktruss1
test_ktruss_errors1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_KTruss.c.gcov.html b/experimental/test/test_KTruss.c.gcov.html new file mode 100644 index 0000000000..acb45a30d7 --- /dev/null +++ b/experimental/test/test_KTruss.c.gcov.html @@ -0,0 +1,280 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_KTruss.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_KTruss.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:8989100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //----------------------------------------------------------------------------
+       2             : // LAGraph/experimental/test/test_KTruss.c: test cases for k-truss
+       3             : // ----------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //-----------------------------------------------------------------------------
+      17             : 
+      18             : #include <stdio.h>
+      19             : #include <acutest.h>
+      20             : 
+      21             : #include "LAGraphX.h"
+      22             : #include "LAGraph_test.h"
+      23             : #include "LG_Xtest.h"
+      24             : 
+      25             : char msg [LAGRAPH_MSG_LEN] ;
+      26             : LAGraph_Graph G = NULL ;
+      27             : GrB_Matrix A = NULL ;
+      28             : GrB_Matrix C1 = NULL, C2 = NULL ;
+      29             : #define LEN 512
+      30             : char filename [LEN+1] ;
+      31             : 
+      32             : typedef struct
+      33             : {
+      34             :     uint32_t ntriangles ;
+      35             :     const char *name ;
+      36             : }
+      37             : matrix_info ;
+      38             : 
+      39             : const matrix_info files [ ] =
+      40             : {
+      41             :     {     11, "A.mtx" },
+      42             :     {   2016, "jagmesh7.mtx" },
+      43             : //  { 342300, "bcsstk13.mtx" },
+      44             :     {     45, "karate.mtx" },
+      45             :     {      6, "ldbc-cdlp-undirected-example.mtx" },
+      46             :     {      4, "ldbc-undirected-example-bool.mtx" },
+      47             :     {      4, "ldbc-undirected-example-unweighted.mtx" },
+      48             :     {      4, "ldbc-undirected-example.mtx" },
+      49             :     {      5, "ldbc-wcc-example.mtx" },
+      50             :     { 0, "" },
+      51             : } ;
+      52             : 
+      53             : //****************************************************************************
+      54           1 : void test_ktruss (void)
+      55             : {
+      56           1 :     LAGraph_Init (msg) ;
+      57             : 
+      58           1 :     for (int id = 0 ; ; id++)
+      59           8 :     {
+      60             : 
+      61             :         // load the matrix as A
+      62           9 :         const char *aname = files [id].name ;
+      63           9 :         uint32_t ntriangles = files [id].ntriangles ;
+      64           9 :         if (strlen (aname) == 0) break;
+      65           8 :         printf ("\n================================== %s:\n", aname) ;
+      66           8 :         TEST_CASE (aname) ;
+      67           8 :         snprintf (filename, LEN, LG_DATA_DIR "%s", aname) ;
+      68           8 :         FILE *f = fopen (filename, "r") ;
+      69           8 :         TEST_CHECK (f != NULL) ;
+      70           8 :         OK (LAGraph_MMRead (&A, f, msg)) ;
+      71           8 :         TEST_MSG ("Loading of adjacency matrix failed") ;
+      72             : 
+      73             :         // construct an undirected graph G with adjacency matrix A
+      74           8 :         OK (LAGraph_New (&G, &A, LAGraph_ADJACENCY_UNDIRECTED, msg)) ;
+      75           8 :         TEST_CHECK (A == NULL) ;
+      76             : 
+      77             :         // check for self-edges
+      78           8 :         OK (LAGraph_Cached_NSelfEdges (G, msg)) ;
+      79           8 :         if (G->nself_edges != 0)
+      80             :         {
+      81             :             // remove self-edges
+      82           1 :             printf ("graph has %g self edges\n", (double) G->nself_edges) ;
+      83           1 :             OK (LAGraph_DeleteSelfEdges (G, msg)) ;
+      84           1 :             printf ("now has %g self edges\n", (double) G->nself_edges) ;
+      85           1 :             TEST_CHECK (G->nself_edges == 0) ;
+      86             :         }
+      87             : 
+      88             :         // compute each k-truss until the result is empty
+      89             :         bool ok ;
+      90             :         GrB_Index n ;
+      91           8 :         OK (GrB_Matrix_nrows (&n, G->A)) ;
+      92          21 :         for (int k = 3 ; k < n ; k++)
+      93             :         {
+      94             :             // compute the k-truss
+      95          21 :             printf ("\n%d-truss:\n", k) ;
+      96          21 :             OK (LAGraph_KTruss (&C1, G, k, msg)) ;
+      97             : 
+      98             :             // compute it again to check the result
+      99          21 :             OK (LG_check_ktruss (&C2, G, k, msg)) ;
+     100          21 :             OK (LAGraph_Matrix_IsEqual (&ok, C1, C2, msg)) ;
+     101          21 :             TEST_CHECK (ok) ;
+     102             : 
+     103             :             // count the triangles in the 3-truss
+     104          21 :             if (k == 3)
+     105             :             {
+     106           8 :                 uint32_t nt = 0 ;
+     107           8 :                 OK (GrB_reduce (&nt, NULL, GrB_PLUS_MONOID_UINT32, C1, NULL)) ;
+     108           8 :                 nt = nt / 6 ;
+     109           8 :                 TEST_CHECK (nt == ntriangles) ;
+     110             :             }
+     111             : 
+     112             :             // free C1 and C2, and break if C1 is empty
+     113             :             GrB_Index nvals ;
+     114          21 :             OK (GrB_Matrix_nvals (&nvals, C1)) ;
+     115          21 :             OK (GrB_free (&C1)) ;
+     116          21 :             OK (GrB_free (&C2)) ;
+     117          21 :             if (nvals == 0) break ;
+     118             :         }
+     119             : 
+     120             :         // convert to directed with symmetric structure and recompute
+     121           8 :         G->kind = LAGraph_ADJACENCY_DIRECTED ;
+     122           8 :         G->is_symmetric_structure = LAGraph_TRUE ;
+     123           8 :         OK (LAGraph_KTruss (&C1, G, 3, msg)) ;
+     124           8 :         OK (LG_check_ktruss (&C2, G, 3, msg)) ;
+     125           8 :         OK (LAGraph_Matrix_IsEqual (&ok, C1, C2, msg)) ;
+     126           8 :         TEST_CHECK (ok) ;
+     127           8 :         OK (GrB_free (&C1)) ;
+     128           8 :         OK (GrB_free (&C2)) ;
+     129             : 
+     130           8 :         OK (LAGraph_Delete (&G, msg)) ;
+     131             :     }
+     132             : 
+     133           1 :     LAGraph_Finalize (msg) ;
+     134           1 : }
+     135             : 
+     136             : //------------------------------------------------------------------------------
+     137             : // test_ktruss_error
+     138             : //------------------------------------------------------------------------------
+     139             : 
+     140           1 : void test_ktruss_errors (void)
+     141             : {
+     142           1 :     LAGraph_Init (msg) ;
+     143             : 
+     144           1 :     snprintf (filename, LEN, LG_DATA_DIR "%s", "karate.mtx") ;
+     145           1 :     FILE *f = fopen (filename, "r") ;
+     146           1 :     TEST_CHECK (f != NULL) ;
+     147           1 :     OK (LAGraph_MMRead (&A, f, msg)) ;
+     148           1 :     TEST_MSG ("Loading of adjacency matrix failed") ;
+     149             : 
+     150             :     // construct an undirected graph G with adjacency matrix A
+     151           1 :     OK (LAGraph_New (&G, &A, LAGraph_ADJACENCY_UNDIRECTED, msg)) ;
+     152           1 :     TEST_CHECK (A == NULL) ;
+     153             : 
+     154           1 :     OK (LAGraph_Cached_NSelfEdges (G, msg)) ;
+     155             : 
+     156             :     // C is NULL
+     157           1 :     int result = LAGraph_KTruss (NULL, G, 3, msg) ;
+     158           1 :     printf ("\nresult: %d %s\n", result, msg) ;
+     159           1 :     TEST_CHECK (result == GrB_NULL_POINTER) ;
+     160             : 
+     161             :     // k is invalid
+     162           1 :     result = LAGraph_KTruss (&C1, G, 2, msg) ;
+     163           1 :     printf ("\nresult: %d %s\n", result, msg) ;
+     164           1 :     TEST_CHECK (result == GrB_INVALID_VALUE) ;
+     165           1 :     TEST_CHECK (C1 == NULL) ;
+     166             : 
+     167             :     // G is invalid
+     168           1 :     result = LAGraph_KTruss (&C1, NULL, 3, msg) ;
+     169           1 :     printf ("\nresult: %d %s\n", result, msg) ;
+     170           1 :     TEST_CHECK (result == GrB_NULL_POINTER) ;
+     171           1 :     TEST_CHECK (C1 == NULL) ;
+     172             : 
+     173             :     // G may have self edges
+     174           1 :     G->nself_edges = LAGRAPH_UNKNOWN ;
+     175           1 :     result = LAGraph_KTruss (&C1, G, 3, msg) ;
+     176           1 :     printf ("\nresult: %d %s\n", result, msg) ;
+     177           1 :     TEST_CHECK (result == -1004) ;
+     178           1 :     TEST_CHECK (C1 == NULL) ;
+     179             : 
+     180             :     // G is undirected
+     181           1 :     G->nself_edges = 0 ;
+     182           1 :     G->kind = LAGraph_ADJACENCY_DIRECTED ;
+     183           1 :     G->is_symmetric_structure = LAGraph_FALSE ;
+     184           1 :     result = LAGraph_KTruss (&C1, G, 3, msg) ;
+     185           1 :     printf ("\nresult: %d %s\n", result, msg) ;
+     186           1 :     TEST_CHECK (result == -1005) ;
+     187           1 :     TEST_CHECK (C1 == NULL) ;
+     188             : 
+     189           1 :     result = LG_check_ktruss (&C1, G, 3, msg) ;
+     190           1 :     printf ("\nresult: %d %s\n", result, msg) ;
+     191           1 :     TEST_CHECK (result == -1005) ;
+     192           1 :     TEST_CHECK (C1 == NULL) ;
+     193             : 
+     194           1 :     OK (LAGraph_Delete (&G, msg)) ;
+     195           1 :     LAGraph_Finalize (msg) ;
+     196           1 : }
+     197             : 
+     198             : //****************************************************************************
+     199             : 
+     200             : TEST_LIST = {
+     201             :     {"ktruss", test_ktruss},
+     202             :     {"ktruss_errors", test_ktruss_errors},
+     203             :     {NULL, NULL}
+     204             : };
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_MaximalIndependentSet.c.func-sort-c.html b/experimental/test/test_MaximalIndependentSet.c.func-sort-c.html new file mode 100644 index 0000000000..22d57388c8 --- /dev/null +++ b/experimental/test/test_MaximalIndependentSet.c.func-sort-c.html @@ -0,0 +1,84 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_MaximalIndependentSet.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_MaximalIndependentSet.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:9797100.0 %
Date:2024-08-29 20:08:04Functions:33100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
setup1
teardown1
test_MIS1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_MaximalIndependentSet.c.func.html b/experimental/test/test_MaximalIndependentSet.c.func.html new file mode 100644 index 0000000000..4bfaf95d51 --- /dev/null +++ b/experimental/test/test_MaximalIndependentSet.c.func.html @@ -0,0 +1,84 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_MaximalIndependentSet.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_MaximalIndependentSet.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:9797100.0 %
Date:2024-08-29 20:08:04Functions:33100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
setup1
teardown1
test_MIS1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_MaximalIndependentSet.c.gcov.html b/experimental/test/test_MaximalIndependentSet.c.gcov.html new file mode 100644 index 0000000000..26c972afdc --- /dev/null +++ b/experimental/test/test_MaximalIndependentSet.c.gcov.html @@ -0,0 +1,327 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_MaximalIndependentSet.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_MaximalIndependentSet.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:9797100.0 %
Date:2024-08-29 20:08:04Functions:33100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph/experimental/test/test_MaximalIndependentSet
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include <stdio.h>
+      19             : #include <acutest.h>
+      20             : #include <LAGraphX.h>
+      21             : #include <LAGraph_test.h>
+      22             : #include <LG_Xtest.h>
+      23             : 
+      24             : //------------------------------------------------------------------------------
+      25             : // test cases
+      26             : //------------------------------------------------------------------------------
+      27             : 
+      28             : const char *files [ ] =
+      29             : {
+      30             :     "A.mtx",
+      31             :     "jagmesh7.mtx",
+      32             :     "bcsstk13.mtx",
+      33             :     "karate.mtx",
+      34             :     "ldbc-cdlp-undirected-example.mtx",
+      35             :     "ldbc-cdlp-directed-example.mtx",
+      36             :     "ldbc-undirected-example-bool.mtx",
+      37             :     "ldbc-undirected-example-unweighted.mtx",
+      38             :     "ldbc-undirected-example.mtx",
+      39             :     "ldbc-wcc-example.mtx",
+      40             :     "LFAT5.mtx",
+      41             :     "LFAT5_two.mtx",
+      42             :     "cryg2500.mtx",
+      43             :     "msf2.mtx",
+      44             :     "olm1000.mtx",
+      45             :     "west0067.mtx",
+      46             :     ""
+      47             : } ;
+      48             : 
+      49             : #define LEN 512
+      50             : char filename [LEN+1] ;
+      51             : 
+      52             : char msg [LAGRAPH_MSG_LEN] ;
+      53             : GrB_Vector mis = NULL, ignore = NULL ;
+      54             : GrB_Matrix A = NULL, C = NULL, empty_row = NULL, empty_col = NULL ;
+      55             : LAGraph_Graph G = NULL ;
+      56             : 
+      57             : //------------------------------------------------------------------------------
+      58             : // setup: start a test
+      59             : //------------------------------------------------------------------------------
+      60             : 
+      61           1 : void setup (void)
+      62             : {
+      63           1 :     OK (LAGraph_Init (msg)) ;
+      64           1 :     OK (LAGraph_Random_Init (msg)) ;
+      65           1 : }
+      66             : 
+      67             : //------------------------------------------------------------------------------
+      68             : // teardown: finalize a test
+      69             : //------------------------------------------------------------------------------
+      70             : 
+      71           1 : void teardown (void)
+      72             : {
+      73           1 :     OK (LAGraph_Random_Finalize (msg)) ;
+      74           1 :     OK (LAGraph_Finalize (msg)) ;
+      75           1 : }
+      76             : 
+      77             : //------------------------------------------------------------------------------
+      78             : // test_MaximalIndependentSet:  test MIS
+      79             : //------------------------------------------------------------------------------
+      80             : 
+      81           1 : void test_MIS (void)
+      82             : {
+      83             :     GrB_Info info ;
+      84           1 :     setup ( ) ;
+      85             : 
+      86           1 :     for (int k = 0 ; ; k++)
+      87          16 :     {
+      88             : 
+      89             :         // load the matrix as A
+      90          17 :         const char *aname = files [k] ;
+      91          17 :         if (strlen (aname) == 0) break;
+      92          16 :         TEST_CASE (aname) ;
+      93          16 :         snprintf (filename, LEN, LG_DATA_DIR "%s", aname) ;
+      94          16 :         FILE *f = fopen (filename, "r") ;
+      95          16 :         TEST_CHECK (f != NULL) ;
+      96          16 :         OK (LAGraph_MMRead (&A, f, msg)) ;
+      97          16 :         OK (fclose (f)) ;
+      98          16 :         TEST_MSG ("Loading of valued matrix failed") ;
+      99          16 :         printf ("\nMatrix: %s\n", aname) ;
+     100             : 
+     101             :         // C = structure of A
+     102          16 :         OK (LAGraph_Matrix_Structure (&C, A, msg)) ;
+     103          16 :         OK (GrB_free (&A)) ;
+     104             : 
+     105             :         // construct a directed graph G with adjacency matrix C
+     106          16 :         OK (LAGraph_New (&G, &C, LAGraph_ADJACENCY_DIRECTED, msg)) ;
+     107          16 :         TEST_CHECK (C == NULL) ;
+     108             : 
+     109             :         // error handling test
+     110          16 :         int result = LAGraph_MaximalIndependentSet (&mis, G, 0, NULL, msg) ;
+     111          16 :         TEST_CHECK (result == -105) ;
+     112          16 :         TEST_CHECK (mis == NULL) ;
+     113             : 
+     114             :         // check if the pattern is symmetric
+     115          16 :         OK (LAGraph_Cached_IsSymmetricStructure (G, msg)) ;
+     116             : 
+     117          16 :         if (G->is_symmetric_structure == LAGraph_FALSE)
+     118             :         {
+     119             :             // make the adjacency matrix symmetric
+     120           5 :             OK (LAGraph_Cached_AT (G, msg)) ;
+     121           5 :             OK (GrB_eWiseAdd (G->A, NULL, NULL, GrB_LOR, G->A, G->AT, NULL)) ;
+     122           5 :             G->is_symmetric_structure = LAGraph_TRUE ;
+     123             :         }
+     124          16 :         G->kind = LAGraph_ADJACENCY_UNDIRECTED ;
+     125             : 
+     126             :         // check for self-edges
+     127          16 :         OK (LAGraph_Cached_NSelfEdges (G, msg)) ;
+     128          16 :         if (G->nself_edges != 0)
+     129             :         {
+     130             :             // remove self-edges
+     131           7 :             printf ("graph has %g self edges\n", (double) G->nself_edges) ;
+     132           7 :             OK (LAGraph_DeleteSelfEdges (G, msg)) ;
+     133           7 :             printf ("now has %g self edges\n", (double) G->nself_edges) ;
+     134           7 :             TEST_CHECK (G->nself_edges == 0) ;
+     135             :         }
+     136             : 
+     137             :         // compute the row degree
+     138          16 :         OK (LAGraph_Cached_OutDegree (G, msg)) ;
+     139             : 
+     140             :         GrB_Index n ;
+     141          16 :         GrB_Matrix_nrows (&n, G->A) ;
+     142             : 
+     143             :         // create ignore
+     144          16 :         OK (GrB_Vector_new (&ignore, GrB_BOOL, n)) ;
+     145         880 :         for (int i = 0 ; i < n ; i += 8)
+     146             :         {
+     147         864 :             OK (GrB_Vector_setElement (ignore, (bool) true, i)) ;
+     148             :         }
+     149             : 
+     150          96 :         for (int64_t seed = 0 ; seed <= 4*n ; seed += n)
+     151             :         {
+     152             :             // compute the MIS with no ignored nodes
+     153          80 :             OK (LAGraph_MaximalIndependentSet (&mis, G, seed, NULL, msg)) ;
+     154             :             // check the result
+     155          80 :             OK (LG_check_mis (G->A, mis, NULL, msg)) ;
+     156          80 :             OK (GrB_free (&mis)) ;
+     157             : 
+     158             :             // compute the MIS with ignored nodes
+     159          80 :             OK (LAGraph_MaximalIndependentSet (&mis, G, seed, ignore, msg)) ;
+     160             :             // check the result
+     161          80 :             OK (LG_check_mis (G->A, mis, ignore, msg)) ;
+     162             : 
+     163          80 :             OK (GrB_free (&mis)) ;
+     164             :         }
+     165             : 
+     166             :         // create some singletons
+     167          16 :         GrB_Index nsingletons = 0 ;
+     168             :         GrB_Index I [1] ;
+     169          16 :         OK (GrB_Matrix_new (&empty_col, GrB_BOOL, n, 1)) ;
+     170          16 :         OK (GrB_Matrix_new (&empty_row, GrB_BOOL, 1, n)) ;
+     171         705 :         for (int64_t i = 0 ; i < n ; i += 10)
+     172             :         {
+     173             :             // make node i a singleton
+     174         689 :             I [0] = i ;
+     175         689 :             OK (GrB_assign (G->A, NULL, NULL, empty_col, GrB_ALL, n, I, 1,
+     176             :                 NULL)) ;
+     177         689 :             OK (GrB_assign (G->A, NULL, NULL, empty_row, I, 1, GrB_ALL, n,
+     178             :                 NULL)) ;
+     179         689 :             nsingletons++ ;
+     180             :         }
+     181          16 :         printf ("creating at least %g singletons\n", (double) nsingletons) ;
+     182             : 
+     183          16 :         OK (LAGraph_DeleteCached (G, msg)) ;
+     184          16 :         G->kind = LAGraph_ADJACENCY_UNDIRECTED ;
+     185          16 :         G->is_symmetric_structure = LAGraph_TRUE ;
+     186          16 :         G->nself_edges = 0 ;
+     187             : 
+     188             :         // recompute the out degree
+     189          16 :         OK (LAGraph_Cached_OutDegree (G, msg)) ;
+     190             : 
+     191             :         GrB_Index nonsingletons, nsingletons_actual ;
+     192          16 :         OK (GrB_Vector_nvals (&nonsingletons, G->out_degree)) ;
+     193          16 :         nsingletons_actual = n - nonsingletons ;
+     194          16 :         printf ("actual # of singletons: %g\n", (double) nsingletons_actual) ;
+     195          16 :         TEST_CHECK (nsingletons <= nsingletons_actual) ;
+     196             : 
+     197          96 :         for (int64_t seed = 0 ; seed <= 4*n ; seed += n)
+     198             :         {
+     199             :             // compute the MIS with no ignored nodes
+     200          80 :             OK (LAGraph_MaximalIndependentSet (&mis, G, seed, NULL, msg)) ;
+     201             :             // check the result
+     202          80 :             OK (LG_check_mis (G->A, mis, NULL, msg)) ;
+     203          80 :             OK (GrB_free (&mis)) ;
+     204             : 
+     205             :             // compute the MIS with ignored nodes
+     206          80 :             OK (LAGraph_MaximalIndependentSet (&mis, G, seed, ignore, msg)) ;
+     207             :             // check the result
+     208          80 :             OK (LG_check_mis (G->A, mis, ignore, msg)) ;
+     209             : 
+     210          80 :             OK (GrB_free (&mis)) ;
+     211             :         }
+     212             : 
+     213             :         // convert to directed with symmetric structure and recompute the MIS
+     214          16 :         G->kind = LAGraph_ADJACENCY_DIRECTED ;
+     215          16 :         OK (LAGraph_MaximalIndependentSet (&mis, G, 0, NULL, msg)) ;
+     216             :         // check the result
+     217          16 :         OK (LG_check_mis (G->A, mis, NULL, msg)) ;
+     218          16 :         OK (GrB_free (&mis)) ;
+     219             : 
+     220             :         // hack the random number generator to induce an error condition
+     221             :         #if defined ( COVERAGE )
+     222          16 :         printf ("Hack the random number generator to induce a stall:\n") ;
+     223          16 :         random_hack = true ;
+     224          16 :         result = LAGraph_MaximalIndependentSet (&mis, G, 0, NULL, msg) ;
+     225          16 :         random_hack = false ;
+     226          16 :         printf ("hack msg: %d %s\n", result, msg) ;
+     227          16 :         TEST_CHECK (result == -111 || result == 0) ;
+     228          16 :         if (result == 0)
+     229             :         {
+     230           3 :             OK (LG_check_mis (G->A, mis, NULL, msg)) ;
+     231             :         }
+     232             :         #endif
+     233             : 
+     234          16 :         OK (GrB_free (&mis)) ;
+     235          16 :         OK (GrB_free (&ignore)) ;
+     236          16 :         OK (GrB_free (&empty_col)) ;
+     237          16 :         OK (GrB_free (&empty_row)) ;
+     238          16 :         OK (LAGraph_Delete (&G, msg)) ;
+     239             :     }
+     240           1 :     teardown ( ) ;
+     241           1 : }
+     242             : 
+     243             : //-----------------------------------------------------------------------------
+     244             : // TEST_LIST: the list of tasks for this entire test
+     245             : //-----------------------------------------------------------------------------
+     246             : 
+     247             : TEST_LIST =
+     248             : {
+     249             :     { "MIS", test_MIS },
+     250             :     { NULL, NULL }
+     251             : } ;
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_Random.c.func-sort-c.html b/experimental/test/test_Random.c.func-sort-c.html new file mode 100644 index 0000000000..1b0b2babe2 --- /dev/null +++ b/experimental/test/test_Random.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_Random.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_Random.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3131100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_Random1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_Random.c.func.html b/experimental/test/test_Random.c.func.html new file mode 100644 index 0000000000..b306bb9ca3 --- /dev/null +++ b/experimental/test/test_Random.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_Random.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_Random.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3131100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_Random1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_Random.c.gcov.html b/experimental/test/test_Random.c.gcov.html new file mode 100644 index 0000000000..80d47c165d --- /dev/null +++ b/experimental/test/test_Random.c.gcov.html @@ -0,0 +1,162 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_Random.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_Random.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3131100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph/src/test/test_Random.c: test cases for random vector generator
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include <stdio.h>
+      19             : #include <acutest.h>
+      20             : 
+      21             : #include <LAGraphX.h>
+      22             : #include <LAGraph_test.h>
+      23             : 
+      24             : char msg [LAGRAPH_MSG_LEN] ;
+      25             : GrB_Vector Seed = NULL ;
+      26             : 
+      27             : //------------------------------------------------------------------------------
+      28             : // test_Random
+      29             : //------------------------------------------------------------------------------
+      30             : 
+      31           1 : void test_Random (void)
+      32             : {
+      33           1 :     LAGraph_Init (msg) ;
+      34           1 :     OK (LAGraph_Random_Init (msg)) ;
+      35             : 
+      36           1 :     uint64_t seed = 42 ;
+      37           1 :     LAGraph_PrintLevel pr = LAGraph_COMPLETE_VERBOSE ;
+      38             : 
+      39           6 :     for (int trial = 0 ; trial <= 4 ; trial++)
+      40             :     {
+      41           5 :         seed++ ;
+      42           5 :         printf ("\n=============================== seed: %g\n", (double) seed) ;
+      43             : 
+      44             :         // generate a seed vector (all entries present)
+      45           5 :         printf ("\nDense random vector:\n") ;
+      46           5 :         GrB_Index n = 8 ;
+      47           5 :         OK (GrB_Vector_new (&Seed, GrB_UINT64, n)) ;
+      48           5 :         OK (GrB_Vector_assign_UINT64 (Seed, NULL, NULL, 0, GrB_ALL, n, NULL)) ;
+      49           5 :         OK (LAGraph_Random_Seed (Seed, seed, msg)) ;
+      50           5 :         OK (LAGraph_Vector_Print (Seed, pr, stdout, NULL)) ;
+      51           5 :         printf ("\nnext dense random vector:\n") ;
+      52           5 :         OK (LAGraph_Random_Next (Seed, msg)) ;
+      53           5 :         OK (LAGraph_Vector_Print (Seed, pr, stdout, NULL)) ;
+      54             : 
+      55             :         // free all workspace
+      56           5 :         OK (GrB_Vector_free (&Seed)) ;
+      57             : 
+      58             :         // generate a sparse seed vector
+      59           5 :         printf ("\nSparse random vector (same seed):\n") ;
+      60           5 :         OK (GrB_Vector_new (&Seed, GrB_UINT64, n)) ;
+      61          25 :         for (int i = 0 ; i < n ; i += 2)
+      62             :         {
+      63          20 :             OK (GrB_Vector_setElement_UINT64 (Seed, 0, i)) ;
+      64             :         }
+      65           5 :         OK (LAGraph_Random_Seed (Seed, seed, msg)) ;
+      66           5 :         OK (LAGraph_Vector_Print (Seed, pr, stdout, NULL)) ;
+      67           5 :         printf ("\nnext sparse random vector:\n") ;
+      68           5 :         OK (LAGraph_Random_Next (Seed, msg)) ;
+      69           5 :         OK (LAGraph_Vector_Print (Seed, pr, stdout, NULL)) ;
+      70             : 
+      71             :         // free all workspace
+      72           5 :         OK (GrB_Vector_free (&Seed)) ;
+      73             :     }
+      74             : 
+      75           1 :     OK (LAGraph_Random_Finalize (msg)) ;
+      76           1 :     LAGraph_Finalize (msg) ;
+      77           1 : }
+      78             : 
+      79             : //------------------------------------------------------------------------------
+      80             : // Test list
+      81             : //------------------------------------------------------------------------------
+      82             : 
+      83             : TEST_LIST = {
+      84             :     {"Random", test_Random},
+      85             :     {NULL, NULL}
+      86             : };
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_Random_Matrix.c.func-sort-c.html b/experimental/test/test_Random_Matrix.c.func-sort-c.html new file mode 100644 index 0000000000..3d91bd324a --- /dev/null +++ b/experimental/test/test_Random_Matrix.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_Random_Matrix.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_Random_Matrix.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:6767100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_Random_Matrix1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_Random_Matrix.c.func.html b/experimental/test/test_Random_Matrix.c.func.html new file mode 100644 index 0000000000..de1fd28729 --- /dev/null +++ b/experimental/test/test_Random_Matrix.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_Random_Matrix.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_Random_Matrix.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:6767100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_Random_Matrix1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_Random_Matrix.c.gcov.html b/experimental/test/test_Random_Matrix.c.gcov.html new file mode 100644 index 0000000000..fb3cc02d07 --- /dev/null +++ b/experimental/test/test_Random_Matrix.c.gcov.html @@ -0,0 +1,205 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_Random_Matrix.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_Random_Matrix.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:6767100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph/src/test/test_Random_Matrix.c: test cases for random matrix generator
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include <stdio.h>
+      19             : #include <acutest.h>
+      20             : #include <LAGraphX.h>
+      21             : #include <LAGraph_test.h>
+      22             : 
+      23             : char msg [LAGRAPH_MSG_LEN] ;
+      24             : GrB_Vector Seed = NULL ;
+      25             : GrB_Matrix A = NULL ;
+      26             : GrB_Type MyInt = NULL ;
+      27             : typedef int myint ;
+      28             : 
+      29             : //------------------------------------------------------------------------------
+      30             : // test_Random_Matrix
+      31             : //------------------------------------------------------------------------------
+      32             : 
+      33           1 : void test_Random_Matrix (void)
+      34             : {
+      35           1 :     LAGraph_Init (msg) ;
+      36           1 :     OK (LAGraph_Random_Init (msg)) ;
+      37             : 
+      38           1 :     uint64_t seed = 42 ;
+      39           1 :     LAGraph_PrintLevel pr = LAGraph_COMPLETE_VERBOSE ;
+      40             : 
+      41           6 :     for (int trial = 0 ; trial <= 4 ; trial++)
+      42             :     {
+      43           5 :         seed++ ;
+      44           5 :         printf ("\n=============================== seed: %g\n", (double) seed) ;
+      45             : 
+      46           5 :         double d = (trial == 4) ? INFINITY : ((double) trial / 4) ;
+      47           5 :         printf ("density: %g, expected values: %g\n", d, d*20) ;
+      48             : 
+      49           5 :         printf ("\n----------------bool:\n") ;
+      50           5 :         OK (LAGraph_Random_Matrix (&A, GrB_BOOL, 4, 5, d, seed, msg)) ;
+      51           5 :         OK (LAGraph_Matrix_Print (A, pr, stdout, NULL)) ;
+      52           5 :         OK (GrB_free (&A)) ;
+      53             : 
+      54           5 :         printf ("\n----------------int8:\n") ;
+      55           5 :         OK (LAGraph_Random_Matrix (&A, GrB_INT8, 4, 5, d, seed, msg)) ;
+      56           5 :         OK (LAGraph_Matrix_Print (A, pr, stdout, NULL)) ;
+      57           5 :         OK (GrB_free (&A)) ;
+      58             : 
+      59           5 :         printf ("\n----------------int16:\n") ;
+      60           5 :         OK (LAGraph_Random_Matrix (&A, GrB_INT16, 4, 5, d, seed, msg)) ;
+      61           5 :         OK (LAGraph_Matrix_Print (A, pr, stdout, NULL)) ;
+      62           5 :         OK (GrB_free (&A)) ;
+      63             : 
+      64           5 :         printf ("\n----------------int32:\n") ;
+      65           5 :         OK (LAGraph_Random_Matrix (&A, GrB_INT32, 4, 5, d, seed, msg)) ;
+      66           5 :         OK (LAGraph_Matrix_Print (A, pr, stdout, NULL)) ;
+      67           5 :         OK (GrB_free (&A)) ;
+      68             : 
+      69           5 :         printf ("\n----------------int64:\n") ;
+      70           5 :         OK (LAGraph_Random_Matrix (&A, GrB_INT64, 4, 5, d, seed, msg)) ;
+      71           5 :         OK (LAGraph_Matrix_Print (A, pr, stdout, NULL)) ;
+      72           5 :         OK (GrB_free (&A)) ;
+      73             : 
+      74           5 :         printf ("\n----------------uint8:\n") ;
+      75           5 :         OK (LAGraph_Random_Matrix (&A, GrB_UINT8, 4, 5, d, seed, msg)) ;
+      76           5 :         OK (LAGraph_Matrix_Print (A, pr, stdout, NULL)) ;
+      77           5 :         OK (GrB_free (&A)) ;
+      78             : 
+      79           5 :         printf ("\n----------------uint16:\n") ;
+      80           5 :         OK (LAGraph_Random_Matrix (&A, GrB_UINT16, 4, 5, d, seed, msg)) ;
+      81           5 :         OK (LAGraph_Matrix_Print (A, pr, stdout, NULL)) ;
+      82           5 :         OK (GrB_free (&A)) ;
+      83             : 
+      84           5 :         printf ("\n----------------uint32:\n") ;
+      85           5 :         OK (LAGraph_Random_Matrix (&A, GrB_UINT32, 4, 5, d, seed, msg)) ;
+      86           5 :         OK (LAGraph_Matrix_Print (A, pr, stdout, NULL)) ;
+      87           5 :         OK (GrB_free (&A)) ;
+      88             : 
+      89           5 :         printf ("\n----------------uint64:\n") ;
+      90           5 :         OK (LAGraph_Random_Matrix (&A, GrB_UINT64, 4, 5, d, seed, msg)) ;
+      91           5 :         OK (LAGraph_Matrix_Print (A, pr, stdout, NULL)) ;
+      92           5 :         OK (GrB_free (&A)) ;
+      93             : 
+      94           5 :         printf ("\n----------------fp32:\n") ;
+      95           5 :         OK (LAGraph_Random_Matrix (&A, GrB_FP32, 4, 5, d, seed, msg)) ;
+      96           5 :         OK (LAGraph_Matrix_Print (A, pr, stdout, NULL)) ;
+      97           5 :         OK (GrB_free (&A)) ;
+      98             : 
+      99           5 :         printf ("\n----------------fp64:\n") ;
+     100           5 :         OK (LAGraph_Random_Matrix (&A, GrB_FP64, 4, 5, d, seed, msg)) ;
+     101           5 :         OK (LAGraph_Matrix_Print (A, pr, stdout, NULL)) ;
+     102           5 :         OK (GrB_free (&A)) ;
+     103             : 
+     104             :     }
+     105             : 
+     106           1 :     printf ("\n----------------empty bool:\n") ;
+     107           1 :     OK (LAGraph_Random_Matrix (&A, GrB_BOOL, 0, 5, 0.5, seed, msg)) ;
+     108           1 :     OK (LAGraph_Matrix_Print (A, pr, stdout, NULL)) ;
+     109           1 :     OK (GrB_free (&A)) ;
+     110             : 
+     111           1 :     printf ("\n----------------invalid type:\n") ;
+     112           1 :     OK (GrB_Type_new (&MyInt, sizeof (myint))) ;
+     113           1 :     int result = LAGraph_Random_Matrix (&A, MyInt, 0, 5, 0.5, seed, msg) ;
+     114           1 :     printf ("result %d msg [%s]\n", result, msg) ;
+     115           1 :     TEST_CHECK (result == GrB_NOT_IMPLEMENTED) ;
+     116           1 :     OK (GrB_free (&MyInt)) ;
+     117             : 
+     118           1 :     OK (LAGraph_Random_Finalize (msg)) ;
+     119           1 :     LAGraph_Finalize (msg) ;
+     120           1 : }
+     121             : 
+     122             : //------------------------------------------------------------------------------
+     123             : // Test list
+     124             : //------------------------------------------------------------------------------
+     125             : 
+     126             : TEST_LIST = {
+     127             :     {"Random_Matrix", test_Random_Matrix},
+     128             :     {NULL, NULL}
+     129             : };
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_SSaveSet.c.func-sort-c.html b/experimental/test/test_SSaveSet.c.func-sort-c.html new file mode 100644 index 0000000000..fb528d3c3f --- /dev/null +++ b/experimental/test/test_SSaveSet.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_SSaveSet.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_SSaveSet.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3434100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_SSaveSet1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_SSaveSet.c.func.html b/experimental/test/test_SSaveSet.c.func.html new file mode 100644 index 0000000000..3df461d158 --- /dev/null +++ b/experimental/test/test_SSaveSet.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_SSaveSet.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_SSaveSet.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3434100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_SSaveSet1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_SSaveSet.c.gcov.html b/experimental/test/test_SSaveSet.c.gcov.html new file mode 100644 index 0000000000..26ffe920f9 --- /dev/null +++ b/experimental/test/test_SSaveSet.c.gcov.html @@ -0,0 +1,244 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_SSaveSet.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_SSaveSet.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3434100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //----------------------------------------------------------------------------
+       2             : // LAGraph/src/test/test_SWrite.c: test cases for LAGraph_SWrite and SRead
+       3             : // ----------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //-----------------------------------------------------------------------------
+      17             : 
+      18             : #include <stdio.h>
+      19             : #include <acutest.h>
+      20             : #include <LAGraphX.h>
+      21             : #include <LAGraph_test.h>
+      22             : 
+      23             : char msg [LAGRAPH_MSG_LEN] ;
+      24             : LAGraph_Graph G = NULL ;
+      25             : GrB_Matrix A = NULL ;
+      26             : GrB_Matrix B = NULL ;
+      27             : GrB_Matrix *S = NULL ;
+      28             : 
+      29             : #define LEN 512
+      30             : char filename [LEN+1] ;
+      31             : 
+      32             : #define NFILES 51
+      33             : const char *files [ ] =
+      34             : {
+      35             :     "A.mtx",
+      36             :     "cover.mtx",
+      37             :     "cover_structure.mtx",
+      38             :     "jagmesh7.mtx",
+      39             :     "ldbc-cdlp-directed-example.mtx",
+      40             :     "ldbc-cdlp-undirected-example.mtx",
+      41             :     "ldbc-directed-example-bool.mtx",
+      42             :     "ldbc-directed-example.mtx",
+      43             :     "ldbc-directed-example-unweighted.mtx",
+      44             :     "ldbc-undirected-example-bool.mtx",
+      45             :     "ldbc-undirected-example.mtx",
+      46             :     "ldbc-undirected-example-unweighted.mtx",
+      47             :     "ldbc-wcc-example.mtx",
+      48             :     "LFAT5.mtx",
+      49             :     "msf1.mtx",
+      50             :     "msf2.mtx",
+      51             :     "msf3.mtx",
+      52             :     "sample2.mtx",
+      53             :     "sample.mtx",
+      54             :     "sources_7.mtx",
+      55             :     "olm1000.mtx",
+      56             :     "bcsstk13.mtx",
+      57             :     "cryg2500.mtx",
+      58             :     "tree-example.mtx",
+      59             :     "west0067.mtx",
+      60             :     "lp_afiro.mtx",
+      61             :     "lp_afiro_structure.mtx",
+      62             :     "karate.mtx",
+      63             :     "matrix_bool.mtx",
+      64             :     "matrix_int8.mtx",
+      65             :     "matrix_int16.mtx",
+      66             :     "matrix_int32.mtx",
+      67             :     "matrix_int64.mtx",
+      68             :     "matrix_uint8.mtx",
+      69             :     "matrix_uint16.mtx",
+      70             :     "matrix_uint32.mtx",
+      71             :     "matrix_uint64.mtx",
+      72             :     "matrix_fp32.mtx",
+      73             :     "matrix_fp32_structure.mtx",
+      74             :     "matrix_fp64.mtx",
+      75             :     "west0067_jumbled.mtx",
+      76             :     "skew_fp32.mtx",
+      77             :     "skew_fp64.mtx",
+      78             :     "skew_int8.mtx",
+      79             :     "skew_int16.mtx",
+      80             :     "skew_int32.mtx",
+      81             :     "skew_int64.mtx",
+      82             :     "structure.mtx",
+      83             :     "full.mtx",
+      84             :     "full_symmetric.mtx",
+      85             :     "empty.mtx",
+      86             :     "",
+      87             : } ;
+      88             : 
+      89             : //****************************************************************************
+      90           1 : void test_SSaveSet (void)
+      91             : {
+      92           1 :     LAGraph_Init (msg) ;
+      93           1 :     GrB_Descriptor desc = NULL ;
+      94             :     #if LAGRAPH_SUITESPARSE
+      95           1 :     OK (GrB_Descriptor_new (&desc)) ;
+      96           1 :     OK (GxB_set (desc, GxB_COMPRESSION, GxB_COMPRESSION_LZ4HC + 9)) ;
+      97             :     #endif
+      98             : 
+      99             :     // load all matrices into a single set
+     100           1 :     GrB_Matrix *Set = NULL ;
+     101           1 :     OK (LAGraph_Malloc ((void **) &Set, NFILES, sizeof (GrB_Matrix), msg)) ;
+     102             : 
+     103          52 :     for (int k = 0 ; k < NFILES ; k++)
+     104             :     {
+     105             :         // load the matrix as Set [k]
+     106          51 :         const char *aname = files [k] ;
+     107          51 :         if (strlen (aname) == 0) break;
+     108          51 :         TEST_CASE (aname) ;
+     109          51 :         snprintf (filename, LEN, LG_DATA_DIR "%s", aname) ;
+     110          51 :         FILE *f = fopen (filename, "r") ;
+     111          51 :         TEST_CHECK (f != NULL) ;
+     112          51 :         OK (LAGraph_MMRead (&(Set [k]), f, msg)) ;
+     113          51 :         fclose (f) ;
+     114             :     }
+     115             : 
+     116             :     // workaround for bug in v6.0.0 to v6.0.2:
+     117             :     // ensure the matrix is not iso
+     118             :     #if LAGRAPH_SUITESPARSE
+     119             :     #if GxB_IMPLEMENTATION < GxB_VERSION (6,0,3)
+     120             :     printf ("\nworkaround for bug in SS:GrB v6.0.2 (fixed in v6.0.3)\n") ;
+     121             :     for (int k = 0 ; k < NFILES ; k++)
+     122             :     {
+     123             :         OK (GrB_Matrix_setElement (Set [k], 0, 0, 0)) ;
+     124             :         OK (GrB_wait (Set [k], GrB_MATERIALIZE)) ;
+     125             :     }
+     126             :     #endif
+     127             :     #endif
+     128             : 
+     129             :     // save the set of matrices in a single file
+     130           1 :     OK (LAGraph_SSaveSet ("matrices.lagraph", Set, NFILES, "many test matrices",
+     131             :         msg)) ;
+     132             : 
+     133             :     // load the matrices back in
+     134           1 :     GrB_Matrix *Set2 = NULL ;
+     135           1 :     GrB_Index nmatrices = 0 ;
+     136           1 :     char *collection = NULL ;
+     137             :     int r =
+     138           1 :         LAGraph_SLoadSet ("matrices.lagraph", &Set2, &nmatrices, &collection,
+     139             :         msg) ;
+     140           1 :     printf ("nmatrices %g r %d msg %s\n", (double) nmatrices, r, msg) ;
+     141           1 :     TEST_CHECK (nmatrices == NFILES) ;
+     142           1 :     TEST_CHECK (Set2 != NULL) ;
+     143           1 :     TEST_CHECK (strcmp (collection, "many test matrices") == 0) ;
+     144             : 
+     145             :     // check the matrices
+     146          52 :     for (int k = 0 ; k < NFILES ; k++)
+     147             :     {
+     148             :         // ensure the matrices Set [k] and Set2 [k] are the same
+     149             :         bool ok ;
+     150          51 :         OK (LAGraph_Matrix_IsEqual (&ok, Set [k], Set2 [k], msg)) ;
+     151          51 :         TEST_CHECK (ok) ;
+     152             :     }
+     153             : 
+     154             :     // free all matrices
+     155           1 :     LAGraph_SFreeSet (&Set, NFILES) ;
+     156           1 :     LAGraph_SFreeSet (&Set2, NFILES) ;
+     157           1 :     LAGraph_Free ((void **) &collection, NULL) ;
+     158             : 
+     159           1 :     OK (GrB_free (&desc)) ;
+     160           1 :     LAGraph_Finalize (msg) ;
+     161           1 : }
+     162             : 
+     163             : //****************************************************************************
+     164             : 
+     165             : TEST_LIST = {
+     166             :     {"SSaveSet", test_SSaveSet},
+     167             :     {NULL, NULL}
+     168             : };
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_SWrite.c.func-sort-c.html b/experimental/test/test_SWrite.c.func-sort-c.html new file mode 100644 index 0000000000..518a03b364 --- /dev/null +++ b/experimental/test/test_SWrite.c.func-sort-c.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_SWrite.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_SWrite.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:142142100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_SWrite1
test_SWrite_errors1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_SWrite.c.func.html b/experimental/test/test_SWrite.c.func.html new file mode 100644 index 0000000000..ad8fb24f37 --- /dev/null +++ b/experimental/test/test_SWrite.c.func.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_SWrite.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_SWrite.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:142142100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_SWrite1
test_SWrite_errors1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_SWrite.c.gcov.html b/experimental/test/test_SWrite.c.gcov.html new file mode 100644 index 0000000000..39a2afcc53 --- /dev/null +++ b/experimental/test/test_SWrite.c.gcov.html @@ -0,0 +1,467 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_SWrite.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_SWrite.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:142142100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //----------------------------------------------------------------------------
+       2             : // LAGraph/src/test/test_SWrite.c: test cases for LAGraph_SWrite and SRead
+       3             : // ----------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //-----------------------------------------------------------------------------
+      17             : 
+      18             : #include <stdio.h>
+      19             : #include <acutest.h>
+      20             : #include <LAGraphX.h>
+      21             : #include <LAGraph_test.h>
+      22             : 
+      23             : char msg [LAGRAPH_MSG_LEN] ;
+      24             : LAGraph_Graph G = NULL ;
+      25             : GrB_Matrix A = NULL ;
+      26             : GrB_Matrix B = NULL ;
+      27             : GrB_Matrix *S = NULL ;
+      28             : 
+      29             : #define LEN 512
+      30             : char filename [LEN+1] ;
+      31             : 
+      32             : GrB_Type atype = NULL ;
+      33             : char atypename [LAGRAPH_MAX_NAME_LEN] ;
+      34             : 
+      35             : #define NFILES 51
+      36             : const char *files [ ] =
+      37             : {
+      38             :     "A.mtx",
+      39             :     "cover.mtx",
+      40             :     "cover_structure.mtx",
+      41             :     "jagmesh7.mtx",
+      42             :     "ldbc-cdlp-directed-example.mtx",
+      43             :     "ldbc-cdlp-undirected-example.mtx",
+      44             :     "ldbc-directed-example-bool.mtx",
+      45             :     "ldbc-directed-example.mtx",
+      46             :     "ldbc-directed-example-unweighted.mtx",
+      47             :     "ldbc-undirected-example-bool.mtx",
+      48             :     "ldbc-undirected-example.mtx",
+      49             :     "ldbc-undirected-example-unweighted.mtx",
+      50             :     "ldbc-wcc-example.mtx",
+      51             :     "LFAT5.mtx",
+      52             :     "msf1.mtx",
+      53             :     "msf2.mtx",
+      54             :     "msf3.mtx",
+      55             :     "sample2.mtx",
+      56             :     "sample.mtx",
+      57             :     "sources_7.mtx",
+      58             :     "olm1000.mtx",
+      59             :     "bcsstk13.mtx",
+      60             :     "cryg2500.mtx",
+      61             :     "tree-example.mtx",
+      62             :     "west0067.mtx",
+      63             :     "lp_afiro.mtx",
+      64             :     "lp_afiro_structure.mtx",
+      65             :     "karate.mtx",
+      66             :     "matrix_bool.mtx",
+      67             :     "matrix_int8.mtx",
+      68             :     "matrix_int16.mtx",
+      69             :     "matrix_int32.mtx",
+      70             :     "matrix_int64.mtx",
+      71             :     "matrix_uint8.mtx",
+      72             :     "matrix_uint16.mtx",
+      73             :     "matrix_uint32.mtx",
+      74             :     "matrix_uint64.mtx",
+      75             :     "matrix_fp32.mtx",
+      76             :     "matrix_fp32_structure.mtx",
+      77             :     "matrix_fp64.mtx",
+      78             :     "west0067_jumbled.mtx",
+      79             :     "skew_fp32.mtx",
+      80             :     "skew_fp64.mtx",
+      81             :     "skew_int8.mtx",
+      82             :     "skew_int16.mtx",
+      83             :     "skew_int32.mtx",
+      84             :     "skew_int64.mtx",
+      85             :     "structure.mtx",
+      86             :     "full.mtx",
+      87             :     "full_symmetric.mtx",
+      88             :     "empty.mtx",
+      89             :     "",
+      90             : } ;
+      91             : 
+      92             : //****************************************************************************
+      93             : 
+      94           1 : void test_SWrite (void)
+      95             : {
+      96           1 :     LAGraph_Init (msg) ;
+      97           1 :     GrB_Descriptor desc = NULL ;
+      98             :     #if LAGRAPH_SUITESPARSE
+      99           1 :     OK (GrB_Descriptor_new (&desc)) ;
+     100           1 :     OK (GxB_set (desc, GxB_COMPRESSION, GxB_COMPRESSION_LZ4HC + 9)) ;
+     101             :     #endif
+     102             : 
+     103          52 :     for (int k = 0 ; k < NFILES ; k++)
+     104             :     {
+     105             : 
+     106             :         // load the matrix as A
+     107          51 :         const char *aname = files [k] ;
+     108          51 :         if (strlen (aname) == 0) break;
+     109          51 :         printf ("\n================================== %d %s:\n", k, aname) ;
+     110          51 :         TEST_CASE (aname) ;
+     111          51 :         snprintf (filename, LEN, LG_DATA_DIR "%s", aname) ;
+     112          51 :         FILE *f = fopen (filename, "r") ;
+     113          51 :         TEST_CHECK (f != NULL) ;
+     114          51 :         OK (LAGraph_MMRead (&A, f, msg)) ;
+     115          51 :         fclose (f) ;
+     116             :         // GxB_print (A, 3) ;
+     117             : 
+     118             :         // get the name of the C typedef for the matrix
+     119          51 :         OK (LAGraph_Matrix_TypeName (atypename, A, msg)) ;
+     120          51 :         OK (LAGraph_TypeFromName (&atype, atypename, msg)) ;
+     121             : 
+     122             :         #if LAGRAPH_SUITESPARSE
+     123         255 :         for (int scon = 1 ; scon <= 8 ; scon = 2*scon)
+     124             :         #endif
+     125             :         {
+     126             :             #if LAGRAPH_SUITESPARSE
+     127             :             // for SuiteSparse only: test all sparsity formats
+     128         204 :             OK (GxB_set (A, GxB_SPARSITY_CONTROL, scon)) ;
+     129             :             #endif
+     130             : 
+     131             :             // workaround for bug in v6.0.0 to v6.0.2:
+     132             :             // ensure the matrix is not iso
+     133             :             #if LAGRAPH_SUITESPARSE
+     134             :             #if GxB_IMPLEMENTATION < GxB_VERSION (6,0,3)
+     135             :             printf ("workaround for bug in SS:GrB v6.0.2 (fixed in v6.0.3)\n") ;
+     136             :             OK (GrB_Matrix_setElement (A, 0, 0, 0)) ;
+     137             :             OK (GrB_wait (A, GrB_MATERIALIZE)) ;
+     138             :             #endif
+     139             :             #endif
+     140             : 
+     141             :             // open a temporary *.lagraph file to hold the matrix
+     142         204 :             f = tmpfile ( ) ;
+     143             :             // snprintf (filename, LEN, "%s.lagraph", aname) ;
+     144             :             // f = fopen (filename, "w") ;
+     145         204 :             TEST_CHECK (f != NULL) ;
+     146             : 
+     147             :             // serialize the matrix
+     148             :             // GxB_set (GxB_BURBLE, true) ;
+     149         204 :             void *blob = NULL ;
+     150         204 :             GrB_Index blob_size = 0 ;
+     151             :             #if LAGRAPH_SUITESPARSE
+     152         204 :             if (k % 2 == 0)
+     153             :             {
+     154             :                 // for SuiteSparse: try GxB for every other matrix
+     155         104 :                 OK (GxB_Matrix_serialize (&blob, &blob_size, A, desc)) ;
+     156             :             }
+     157             :             else
+     158             :             #endif
+     159             :             {
+     160             :                 // try GrB version
+     161         100 :                 OK (GrB_Matrix_serializeSize (&blob_size, A)) ;
+     162         100 :                 GrB_Index blob_size_old = blob_size ;
+     163         100 :                 OK (LAGraph_Malloc ((void **) &blob, blob_size,
+     164             :                     sizeof (uint8_t), msg)) ;
+     165         100 :                 TEST_CHECK (blob != NULL) ;
+     166         100 :                 OK (GrB_Matrix_serialize (blob, &blob_size, A)) ;
+     167         100 :                 OK (LAGraph_Realloc ((void **) &blob, blob_size,
+     168             :                     blob_size_old, sizeof (uint8_t), msg)) ;
+     169             :             }
+     170             : 
+     171             :             // deserialize the matrix
+     172         204 :             int rr = (GrB_Matrix_deserialize (&B, atype, blob, blob_size)) ;
+     173             :             // printf ("A:\n") ; GxB_print (A, 2) ;
+     174             :             // printf ("B:\n") ; GxB_print (B, 2) ;
+     175             :             // printf ("rr: %d\n", rr) ;
+     176         204 :             OK (rr) ;
+     177             :             // GxB_set (GxB_BURBLE, false) ;
+     178             : 
+     179             :             // ensure the matrices A and B are the same
+     180             :             // GxB_print (A,3) ;
+     181             :             // GxB_print (B,3) ;
+     182         204 :             bool ok = false ;
+     183         204 :             OK (LAGraph_Matrix_IsEqual (&ok, A, B, msg)) ;
+     184         204 :             TEST_CHECK (ok) ;
+     185         204 :             OK (GrB_free (&B)) ;
+     186             : 
+     187             :             // write the header for a single matrix
+     188         204 :             OK (LAGraph_SWrite_HeaderStart (f, "lagraph_test", msg)) ;
+     189         204 :             OK (LAGraph_SWrite_HeaderItem (f, LAGraph_matrix_kind, "A",
+     190             :                 atypename, 0, blob_size, msg)) ;
+     191         204 :             OK (LAGraph_SWrite_HeaderEnd (f, msg)) ;
+     192             : 
+     193             :             // write the binary blob to the file then free the blob
+     194         204 :             OK (LAGraph_SWrite_Item (f, blob, blob_size, msg)) ;
+     195         204 :             LAGraph_Free (&blob, NULL) ;
+     196             : 
+     197             :             // open the file and load back the contents
+     198         204 :             rewind (f) ;
+     199             :             // fclose (f) ;
+     200             :             // f = fopen (filename, "r") ;
+     201             : 
+     202         204 :             char *collection = NULL ;
+     203         204 :             LAGraph_Contents *Contents = NULL ;
+     204             :             GrB_Index ncontents ;
+     205         204 :             OK (LAGraph_SRead (f, &collection, &Contents, &ncontents, msg)) ;
+     206         204 :             TEST_CHECK (collection != NULL) ;
+     207         204 :             if (collection == NULL) abort ( ) ;
+     208             :             // printf ("collection %s\n", collection) ;
+     209         204 :             TEST_CHECK (strcmp (collection, "lagraph_test") == 0) ;
+     210         204 :             TEST_CHECK (ncontents == 1) ;
+     211         204 :             fclose (f) ;
+     212             : 
+     213             :             // convert the contents to a matrix B
+     214         204 :             void *blob2 = Contents [0].blob ;
+     215         204 :             size_t blob_size2 = Contents [0].blob_size ;
+     216             :             // printf ("blob_size2 %lu\n", blob_size2) ;
+     217         204 :             TEST_CHECK (blob_size == blob_size2) ;
+     218             : 
+     219         204 :             OK (GrB_Matrix_deserialize (&B, atype, blob2, blob_size2)) ;
+     220             :             // GxB_set (GxB_BURBLE, false) ;
+     221             : 
+     222             :             // ensure the matrices A and B are the same
+     223             :             // GxB_print (A,3) ;
+     224             :             // GxB_print (B,3) ;
+     225         204 :             OK (LAGraph_Matrix_IsEqual (&ok, A, B, msg)) ;
+     226         204 :             TEST_CHECK (ok) ;
+     227         204 :             OK (GrB_free (&B)) ;
+     228             : 
+     229             :             // free the contents: todo make this a utility function
+     230         204 :             LAGraph_Free ((void **) &collection, NULL) ;
+     231         408 :             for (int i = 0 ; i < ncontents ; i++)
+     232             :             {
+     233         204 :                 LAGraph_Contents *Item = &(Contents [i]) ;
+     234         204 :                 LAGraph_Free ((void **) &(Item->blob), NULL) ;
+     235             :             }
+     236         204 :             LAGraph_Free ((void **) &Contents, NULL) ;
+     237             :         }
+     238             : 
+     239          51 :         OK (GrB_free (&A)) ;
+     240             :     }
+     241             : 
+     242           1 :     OK (GrB_free (&desc)) ;
+     243           1 :     LAGraph_Finalize (msg) ;
+     244           1 : }
+     245             : 
+     246             : //------------------------------------------------------------------------------
+     247             : 
+     248           1 : void test_SWrite_errors (void)
+     249             : {
+     250           1 :     LAGraph_Init (msg) ;
+     251             : 
+     252             :     // create a simple test matrix
+     253           1 :     GrB_Index n = 5 ;
+     254           1 :     OK (GrB_Matrix_new (&A, GrB_FP32, n, n)) ;
+     255           1 :     OK (GrB_assign (A, NULL, NULL, 0, GrB_ALL, n, GrB_ALL, n, NULL)) ;
+     256           1 :     OK (GrB_apply (A, NULL, NULL, GrB_ROWINDEX_INT64, A, 0, NULL)) ;
+     257           1 :     printf ("\nTest matrix:\n") ;
+     258           1 :     OK (LAGraph_Matrix_Print (A, LAGraph_COMPLETE, stdout, msg)) ;
+     259             : 
+     260             :     // serialize the matrix
+     261             :     bool ok ;
+     262           1 :     void *blob = NULL ;
+     263           1 :     GrB_Index blob_size = 0 ;
+     264             :     #if LAGRAPH_SUITESPARSE
+     265             :     {
+     266             :         // for SuiteSparse
+     267           1 :         OK (GxB_Matrix_serialize (&blob, &blob_size, A, NULL)) ;
+     268             :     }
+     269             :     #else
+     270             :     {
+     271             :         // use GrB version
+     272             :         OK (GrB_Matrix_serializeSize (&blob_size, A)) ;
+     273             :         GrB_Index blob_size_old = blob_size ;
+     274             :         OK (LAGraph_Malloc ((void **) &blob, blob_size, sizeof (uint8_t), msg));
+     275             :         TEST_CHECK (blob != NULL) ;
+     276             :         OK (GrB_Matrix_serialize (blob, &blob_size, A)) ;
+     277             :         OK (LAGraph_Realloc ((void **) &blob, blob_size,
+     278             :             blob_size_old, sizeof (uint8_t), msg)) ;
+     279             :     }
+     280             :     #endif
+     281             : 
+     282           1 :     FILE *f = tmpfile ( )  ;
+     283           1 :     TEST_CHECK (f != NULL) ;
+     284             : 
+     285           1 :     int result = LAGraph_SWrite_HeaderItem (f, -2, "A",
+     286             :         "float", 0, blob_size, msg) ;
+     287           1 :     printf ("result: %d [%s]\n", result, msg) ;
+     288           1 :     TEST_CHECK (result == GrB_INVALID_VALUE) ;
+     289           1 :     fclose (f) ;
+     290             : 
+     291           1 :     f = fopen ("error.lagraph", "wb") ;
+     292           1 :     TEST_CHECK (f != NULL) ;
+     293             : 
+     294           1 :     result = LAGraph_SWrite_HeaderStart (f, NULL, msg) ;
+     295           1 :     TEST_CHECK (result == GrB_NULL_POINTER) ;
+     296             : 
+     297           1 :     result = LAGraph_SWrite_HeaderStart (NULL, "stuff", msg) ;
+     298           1 :     TEST_CHECK (result == GrB_NULL_POINTER) ;
+     299             : 
+     300           1 :     OK (LAGraph_SWrite_HeaderStart (f, "lagraph_test", msg)) ;
+     301             : 
+     302           1 :     result = LAGraph_SWrite_HeaderItem (NULL, LAGraph_matrix_kind, "A",
+     303             :         "float", 0, blob_size, msg) ;
+     304           1 :     TEST_CHECK (result == GrB_NULL_POINTER) ;
+     305             : 
+     306           1 :     result = LAGraph_SWrite_HeaderItem (NULL, -2, "A",
+     307             :         "float", 0, blob_size, msg) ;
+     308           1 :     TEST_CHECK (result == GrB_NULL_POINTER) ;
+     309             : 
+     310           1 :     OK (LAGraph_SWrite_HeaderItem (f, LAGraph_matrix_kind, "A",
+     311             :         "float", 0, blob_size, msg)) ;
+     312             : 
+     313           1 :     result = LAGraph_SWrite_HeaderEnd (NULL, msg) ;
+     314           1 :     TEST_CHECK (result == GrB_NULL_POINTER) ;
+     315             : 
+     316           1 :     OK (LAGraph_SWrite_HeaderEnd (f, msg)) ;
+     317             : 
+     318             :     // write the binary blob to the file then free the blob
+     319           1 :     OK (LAGraph_SWrite_Item (f, blob, blob_size, msg)) ;
+     320           1 :     LAGraph_Free (&blob, NULL) ;
+     321             : 
+     322           1 :     result = LAGraph_SWrite_Item (NULL, blob, blob_size, msg) ;
+     323           1 :     TEST_CHECK (result == GrB_NULL_POINTER) ;
+     324             : 
+     325           1 :     result = LAGraph_SWrite_Item (f, NULL, blob_size, msg) ;
+     326           1 :     TEST_CHECK (result == GrB_NULL_POINTER) ;
+     327             : 
+     328             :     // close the file and reopen it
+     329           1 :     fclose (f) ;
+     330           1 :     f = fopen ("error.lagraph", "r") ;
+     331           1 :     TEST_CHECK (f != NULL) ;
+     332             : 
+     333             :     // load in the matrix
+     334           1 :     GrB_Matrix *Set = NULL ;
+     335           1 :     GrB_Index nmatrices = 0 ;
+     336           1 :     char *collection = NULL ;
+     337             : 
+     338           1 :     result = LAGraph_SLoadSet ("error.lagraph", NULL, &nmatrices,
+     339             :         &collection, msg) ;
+     340           1 :     TEST_CHECK (result == GrB_NULL_POINTER) ;
+     341             : 
+     342           1 :     result = LAGraph_SLoadSet ("unknown.lagraph", &Set, &nmatrices,
+     343             :         &collection, msg) ;
+     344           1 :     printf ("\nresult %d, [%s]\n", result, msg) ;
+     345           1 :     TEST_CHECK (result == -1002) ;
+     346             : 
+     347             :     // mangled file
+     348           1 :     result = LAGraph_SLoadSet (LG_DATA_DIR "garbage.lagraph",
+     349             :         &Set, &nmatrices, &collection, msg) ;
+     350           1 :     printf ("\nresult %d, [%s]\n", result, msg) ;
+     351           1 :     TEST_CHECK (result == LAGRAPH_IO_ERROR) ;
+     352             : 
+     353             :     // finally works
+     354           1 :     OK (LAGraph_SLoadSet ("error.lagraph", &Set, &nmatrices, &collection,
+     355             :         msg)) ;
+     356           1 :     TEST_CHECK (Set != NULL) ;
+     357           1 :     TEST_CHECK (collection != NULL) ;
+     358           1 :     TEST_CHECK (nmatrices == 1) ;
+     359             : 
+     360           1 :     ok = false ;
+     361           1 :     OK (LAGraph_Matrix_IsEqual (&ok, A, Set [0], msg)) ;
+     362           1 :     TEST_CHECK (ok) ;
+     363             : 
+     364             :     // free everything
+     365           1 :     LAGraph_SFreeSet (&Set, nmatrices) ;
+     366           1 :     LAGraph_Free ((void **) &collection, NULL) ;
+     367           1 :     fclose (f) ;
+     368             : 
+     369             :     // read garbage with LAGraph_SRead
+     370           1 :     f = fopen (LG_DATA_DIR "garbage.lagraph", "r") ;
+     371           1 :     TEST_CHECK (f != NULL) ;
+     372           1 :     LAGraph_Contents *Contents = NULL ;
+     373           1 :     GrB_Index ncontents = 0 ;
+     374           1 :     result = LAGraph_SRead (f, &collection, &Contents, &ncontents, msg) ;
+     375           1 :     TEST_CHECK (result = -1001) ;
+     376           1 :     TEST_CHECK (collection == NULL) ;
+     377           1 :     TEST_CHECK (Contents == NULL) ;
+     378           1 :     TEST_CHECK (ncontents == 0) ;
+     379           1 :     fclose (f) ;
+     380             : 
+     381           1 :     OK (GrB_free (&A)) ;
+     382           1 :     LAGraph_Finalize (msg) ;
+     383           1 : }
+     384             : 
+     385             : //****************************************************************************
+     386             : 
+     387             : TEST_LIST = {
+     388             :     {"SWrite", test_SWrite},
+     389             :     {"SWrite_errors", test_SWrite_errors},
+     390             :     {NULL, NULL}
+     391             : };
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_SquareClustering.c.func-sort-c.html b/experimental/test/test_SquareClustering.c.func-sort-c.html new file mode 100644 index 0000000000..ee2c5ba9fd --- /dev/null +++ b/experimental/test/test_SquareClustering.c.func-sort-c.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_SquareClustering.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_SquareClustering.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:2727100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_SquareClustering1
is_close8
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_SquareClustering.c.func.html b/experimental/test/test_SquareClustering.c.func.html new file mode 100644 index 0000000000..ac625bb636 --- /dev/null +++ b/experimental/test/test_SquareClustering.c.func.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_SquareClustering.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_SquareClustering.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:2727100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
is_close8
test_SquareClustering1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_SquareClustering.c.gcov.html b/experimental/test/test_SquareClustering.c.gcov.html new file mode 100644 index 0000000000..f292800fcd --- /dev/null +++ b/experimental/test/test_SquareClustering.c.gcov.html @@ -0,0 +1,183 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_SquareClustering.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_SquareClustering.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:2727100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph/expirimental/test/test_SquareClustering.c: test cases for
+       3             : // square clustering
+       4             : // -----------------------------------------------------------------------------
+       5             : 
+       6             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       7             : // SPDX-License-Identifier: BSD-2-Clause
+       8             : //
+       9             : // For additional details (including references to third party source code and
+      10             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      11             : // Contributors.txt for a full list of contributors. Created, in part, with
+      12             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      13             : // DM22-0790
+      14             : 
+      15             : // Contributed by Erik Welch, NVIDIA
+      16             : 
+      17             : //------------------------------------------------------------------------------
+      18             : 
+      19             : #include <stdio.h>
+      20             : #include <acutest.h>
+      21             : 
+      22             : #include <LAGraphX.h>
+      23             : #include <LAGraph_test.h>
+      24             : #include "LG_Xtest.h"
+      25             : 
+      26             : char msg [LAGRAPH_MSG_LEN] ;
+      27             : 
+      28             : // Data from NetworkX, test_lind_square_clustering: https://github.com/networkx\
+      29             : //      /networkx/blob/main/networkx/algorithms/tests/test_cluster.py
+      30             : GrB_Index rows[19] = {1, 1, 1, 1, 2, 2, 3, 3, 6, 7, 6, 7, 7, 6, 6, 2, 2, 3, 3} ;
+      31             : GrB_Index cols[19] = {2, 3, 6, 7, 4, 5, 4, 5, 7, 8, 8, 9, 10, 11, 12, 13, 14,
+      32             :     15, 16} ;
+      33             : int64_t vals[19] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1} ;
+      34             : 
+      35             : GrB_Index soln_indices[8] = {1, 2, 3, 4, 5, 6, 7, 8} ;
+      36             : double soln_values[8] = {
+      37             :     3.0 / 43.0,
+      38             :     3.0 / 17.0,
+      39             :     3.0 / 17.0,
+      40             :     1.0 / 3.0,
+      41             :     1.0 / 3.0,
+      42             :     1.0 / 27.0,
+      43             :     1.0 / 27.0,
+      44             :     1.0 / 5.0
+      45             : };
+      46             : 
+      47             : //------------------------------------------------------------------------------
+      48             : // is_close: check whether two floats are close
+      49             : //------------------------------------------------------------------------------
+      50             : 
+      51           8 : bool is_close (double a, double b)
+      52             : {
+      53           8 :     double abs_diff = fabs(a - b) ;
+      54           8 :     return abs_diff < 1e-6 ;
+      55             : }
+      56             : 
+      57           1 : void test_SquareClustering (void)
+      58             : {
+      59           1 :     LAGraph_Init (msg) ;
+      60             : 
+      61           1 :     GrB_Matrix A = NULL ;
+      62           1 :     LAGraph_Graph G = NULL ;
+      63             : 
+      64           1 :     GrB_Index n = 17;
+      65           1 :     OK (GrB_Matrix_new (&A, GrB_INT64, n, n)) ;
+      66           1 :     OK (GrB_Matrix_build_INT64 (A, rows, cols, vals, 19, GrB_PLUS_INT64)) ;
+      67             :     // Symmetrize A
+      68           1 :     OK (GrB_Matrix_eWiseAdd_BinaryOp(A, NULL, NULL, GrB_FIRST_INT64, A, A,
+      69             :         GrB_DESC_T1));
+      70           1 :     OK (LAGraph_New (&G, &A, LAGraph_ADJACENCY_UNDIRECTED, msg)) ;
+      71           1 :     TEST_CHECK (A == NULL) ;
+      72             : 
+      73             :     // check for self-edges
+      74           1 :     OK (LAGraph_Cached_NSelfEdges (G, msg)) ;
+      75           1 :     bool sanitize = (G->nself_edges != 0) ;
+      76             : 
+      77           1 :     OK (LAGraph_Cached_OutDegree (G, msg)) ;
+      78             : 
+      79           1 :     GrB_Vector c = NULL ;
+      80           1 :     OK (LAGraph_SquareClustering (&c, G, msg)) ;
+      81             : 
+      82             :     GrB_Index nvals;
+      83           1 :     OK (GrB_Vector_nvals(&nvals, c)) ;
+      84           1 :     TEST_CHECK (nvals == 8) ;
+      85             : 
+      86             :     // OK (GrB_Vector_new(&soln, GrB_FP64, n)) ;
+      87             :     // OK (GrB_Vector_build_FP64(soln, soln_indices, soln_values, 8,
+      88             :     //     GrB_PLUS_FP64)) ;
+      89             :     double val;
+      90           9 :     for (GrB_Index i = 0 ; i < 8 ; ++i)
+      91             :     {
+      92           8 :         GrB_Vector_extractElement_FP64(&val, c, soln_indices[i]) ;
+      93           8 :         TEST_CHECK (is_close(val, soln_values[i])) ;
+      94             :     }
+      95             :     // OK (GrB_free (&soln)) ;
+      96             : 
+      97           1 :     OK (GrB_free (&c)) ;
+      98           1 :     OK (LAGraph_Delete (&G, msg)) ;
+      99             : 
+     100           1 :     LAGraph_Finalize (msg) ;
+     101           1 : };
+     102             : 
+     103             : TEST_LIST = {
+     104             :     {"SquareClustering", test_SquareClustering},
+     105             :     // {"SquareClustering_errors", test_errors},
+     106             :     {NULL, NULL}
+     107             : };
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_TriangleCentrality.c.func-sort-c.html b/experimental/test/test_TriangleCentrality.c.func-sort-c.html new file mode 100644 index 0000000000..f8f18d2d9a --- /dev/null +++ b/experimental/test/test_TriangleCentrality.c.func-sort-c.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_TriangleCentrality.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_TriangleCentrality.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:7878100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_TriangleCentrality1
test_errors1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_TriangleCentrality.c.func.html b/experimental/test/test_TriangleCentrality.c.func.html new file mode 100644 index 0000000000..e04796ab8c --- /dev/null +++ b/experimental/test/test_TriangleCentrality.c.func.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_TriangleCentrality.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_TriangleCentrality.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:7878100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_TriangleCentrality1
test_errors1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_TriangleCentrality.c.gcov.html b/experimental/test/test_TriangleCentrality.c.gcov.html new file mode 100644 index 0000000000..ccc25814b8 --- /dev/null +++ b/experimental/test/test_TriangleCentrality.c.gcov.html @@ -0,0 +1,265 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_TriangleCentrality.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_TriangleCentrality.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:7878100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph/src/test/test_TriangleCentrality.c: test cases for triangle
+       3             : // centrality
+       4             : //------------------------------------------------------------------------------
+       5             : 
+       6             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       7             : // SPDX-License-Identifier: BSD-2-Clause
+       8             : //
+       9             : // For additional details (including references to third party source code and
+      10             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      11             : // Contributors.txt for a full list of contributors. Created, in part, with
+      12             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      13             : // DM22-0790
+      14             : 
+      15             : // Contributed by Timothy A. Davis, Texas A&M University
+      16             : 
+      17             : //------------------------------------------------------------------------------
+      18             : 
+      19             : #include <stdio.h>
+      20             : #include <acutest.h>
+      21             : 
+      22             : #include <LAGraphX.h>
+      23             : #include <LAGraph_test.h>
+      24             : 
+      25             : char msg [LAGRAPH_MSG_LEN] ;
+      26             : LAGraph_Graph G = NULL ;
+      27             : GrB_Matrix A = NULL ;
+      28             : GrB_Matrix C = NULL ;
+      29             : #define LEN 512
+      30             : char filename [LEN+1] ;
+      31             : 
+      32             : typedef struct
+      33             : {
+      34             :     uint64_t ntriangles ;
+      35             :     const char *name ;
+      36             : }
+      37             : matrix_info ;
+      38             : 
+      39             : const matrix_info files [ ] =
+      40             : {
+      41             :     {     11, "A.mtx" },
+      42             :     {   2016, "jagmesh7.mtx" },
+      43             :     { 342300, "bcsstk13.mtx" },
+      44             :     {     45, "karate.mtx" },
+      45             :     {      6, "ldbc-cdlp-undirected-example.mtx" },
+      46             :     {      4, "ldbc-undirected-example-bool.mtx" },
+      47             :     {      4, "ldbc-undirected-example-unweighted.mtx" },
+      48             :     {      4, "ldbc-undirected-example.mtx" },
+      49             :     {      5, "ldbc-wcc-example.mtx" },
+      50             :     { 0, "" },
+      51             : } ;
+      52             : 
+      53             : //****************************************************************************
+      54           1 : void test_TriangleCentrality (void)
+      55             : {
+      56           1 :     LAGraph_Init (msg) ;
+      57             : 
+      58           1 :     for (int k = 0 ; ; k++)
+      59           9 :     {
+      60             : 
+      61             :         // load the matrix as A
+      62          10 :         const char *aname = files [k].name ;
+      63          10 :         uint64_t ntriangles = files [k].ntriangles ;
+      64          10 :         if (strlen (aname) == 0) break;
+      65           9 :         printf ("\n================================== %s:\n", aname) ;
+      66           9 :         TEST_CASE (aname) ;
+      67           9 :         snprintf (filename, LEN, LG_DATA_DIR "%s", aname) ;
+      68           9 :         FILE *f = fopen (filename, "r") ;
+      69           9 :         TEST_CHECK (f != NULL) ;
+      70           9 :         OK (LAGraph_MMRead (&A, f, msg)) ;
+      71             : 
+      72             :         // C = spones (A), in FP64, required for methods 1 and 1.5
+      73             :         GrB_Index n ;
+      74           9 :         OK (GrB_Matrix_nrows (&n, A)) ;
+      75           9 :         OK (GrB_Matrix_new (&C, GrB_FP64, n, n)) ;
+      76           9 :         OK (GrB_assign (C, A, NULL, (double) 1, GrB_ALL, n, GrB_ALL, n,
+      77             :             GrB_DESC_S)) ;
+      78           9 :         OK (GrB_free (&A)) ;
+      79           9 :         TEST_CHECK (A == NULL) ;
+      80           9 :         OK (fclose (f)) ;
+      81           9 :         TEST_MSG ("Loading of adjacency matrix failed") ;
+      82             : 
+      83             :         // construct an undirected graph G with adjacency matrix C
+      84           9 :         OK (LAGraph_New (&G, &C, LAGraph_ADJACENCY_UNDIRECTED, msg)) ;
+      85           9 :         TEST_CHECK (C == NULL) ;
+      86             : 
+      87             :         // check for self-edges
+      88           9 :         OK (LAGraph_Cached_NSelfEdges (G, msg)) ;
+      89           9 :         if (G->nself_edges != 0)
+      90             :         {
+      91             :             // remove self-edges
+      92           2 :             printf ("graph has %g self edges\n", (double) G->nself_edges) ;
+      93           2 :             OK (LAGraph_DeleteSelfEdges (G, msg)) ;
+      94           2 :             printf ("now has %g self edges\n", (double) G->nself_edges) ;
+      95           2 :             TEST_CHECK (G->nself_edges == 0) ;
+      96             :         }
+      97             : 
+      98             :         uint64_t ntri ;
+      99           9 :         GrB_Vector c = NULL ;
+     100          45 :         for (int method = 0 ; method <= 3 ; method++)
+     101             :         {
+     102          36 :             printf ("\nMethod: %d\n", method) ;
+     103             : 
+     104             :             // compute the triangle centrality
+     105          36 :             OK (LAGraph_VertexCentrality_Triangle (&c, &ntri, method, G, msg)) ;
+     106          36 :             printf ("# of triangles: %g\n", (double) ntri) ;
+     107          36 :             TEST_CHECK (ntri == ntriangles) ;
+     108             : 
+     109             :             LAGraph_PrintLevel
+     110          36 :                 pr = (n <= 100) ? LAGraph_COMPLETE : LAGraph_SHORT ;
+     111          36 :             printf ("\ncentrality:\n") ;
+     112          36 :             OK (LAGraph_Vector_Print (c, pr, stdout, msg)) ;
+     113          36 :             OK (GrB_free (&c)) ;
+     114             :         }
+     115             : 
+     116             :         // convert to directed with symmetric structure and recompute
+     117           9 :         G->kind = LAGraph_ADJACENCY_DIRECTED ;
+     118           9 :         OK (LAGraph_VertexCentrality_Triangle (&c, &ntri, 0, G, msg)) ;
+     119           9 :         TEST_CHECK (ntri == ntriangles) ;
+     120           9 :         GrB_free (&c) ;
+     121             : 
+     122           9 :         OK (LAGraph_Delete (&G, msg)) ;
+     123             :     }
+     124             : 
+     125           1 :     LAGraph_Finalize (msg) ;
+     126           1 : }
+     127             : 
+     128             : //------------------------------------------------------------------------------
+     129             : // test_errors
+     130             : //------------------------------------------------------------------------------
+     131             : 
+     132           1 : void test_errors (void)
+     133             : {
+     134           1 :     LAGraph_Init (msg) ;
+     135             : 
+     136           1 :     snprintf (filename, LEN, LG_DATA_DIR "%s", "karate.mtx") ;
+     137           1 :     FILE *f = fopen (filename, "r") ;
+     138           1 :     TEST_CHECK (f != NULL) ;
+     139           1 :     OK (LAGraph_MMRead (&A, f, msg)) ;
+     140           1 :     TEST_MSG ("Loading of adjacency matrix failed") ;
+     141             : 
+     142             :     // construct an undirected graph G with adjacency matrix A
+     143           1 :     OK (LAGraph_New (&G, &A, LAGraph_ADJACENCY_UNDIRECTED, msg)) ;
+     144           1 :     TEST_CHECK (A == NULL) ;
+     145             : 
+     146           1 :     OK (LAGraph_Cached_NSelfEdges (G, msg)) ;
+     147             : 
+     148             :     uint64_t ntri ;
+     149           1 :     GrB_Vector c = NULL ;
+     150             : 
+     151             :     // c is NULL
+     152           1 :     int result = LAGraph_VertexCentrality_Triangle (NULL, &ntri, 3, G, msg) ;
+     153           1 :     printf ("\nresult: %d %s\n", result, msg) ;
+     154           1 :     TEST_CHECK (result == GrB_NULL_POINTER) ;
+     155             : 
+     156             :     // G is invalid
+     157           1 :     result = LAGraph_VertexCentrality_Triangle (&c, &ntri, 3, NULL, msg) ;
+     158           1 :     printf ("\nresult: %d %s\n", result, msg) ;
+     159           1 :     TEST_CHECK (result == GrB_NULL_POINTER) ;
+     160           1 :     TEST_CHECK (c == NULL) ;
+     161             : 
+     162             :     // G may have self edges
+     163           1 :     G->nself_edges = LAGRAPH_UNKNOWN ;
+     164           1 :     result = LAGraph_VertexCentrality_Triangle (&c, &ntri, 3, G, msg) ;
+     165           1 :     printf ("\nresult: %d %s\n", result, msg) ;
+     166           1 :     TEST_CHECK (result == -1004) ;
+     167           1 :     TEST_CHECK (c == NULL) ;
+     168             : 
+     169             :     // G is undirected
+     170           1 :     G->nself_edges = 0 ;
+     171           1 :     G->kind = LAGraph_ADJACENCY_DIRECTED ;
+     172           1 :     G->is_symmetric_structure = LAGraph_FALSE ;
+     173           1 :     result = LAGraph_VertexCentrality_Triangle (&c, &ntri, 3, G, msg) ;
+     174           1 :     printf ("\nresult: %d %s\n", result, msg) ;
+     175           1 :     TEST_CHECK (result == -1005) ;
+     176           1 :     TEST_CHECK (c == NULL) ;
+     177             : 
+     178           1 :     OK (LAGraph_Delete (&G, msg)) ;
+     179           1 :     LAGraph_Finalize (msg) ;
+     180           1 : }
+     181             : 
+     182             : 
+     183             : //****************************************************************************
+     184             : 
+     185             : TEST_LIST = {
+     186             :     {"TriangleCentrality", test_TriangleCentrality},
+     187             :     {"TriangleCentrality_errors", test_errors},
+     188             :     {NULL, NULL}
+     189             : };
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_cdlp.c.func-sort-c.html b/experimental/test/test_cdlp.c.func-sort-c.html new file mode 100644 index 0000000000..31b1b87c7d --- /dev/null +++ b/experimental/test/test_cdlp.c.func-sort-c.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_cdlp.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_cdlp.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:6161100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_cdlp1
test_errors1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_cdlp.c.func.html b/experimental/test/test_cdlp.c.func.html new file mode 100644 index 0000000000..3c4e5de810 --- /dev/null +++ b/experimental/test/test_cdlp.c.func.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_cdlp.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_cdlp.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:6161100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_cdlp1
test_errors1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_cdlp.c.gcov.html b/experimental/test/test_cdlp.c.gcov.html new file mode 100644 index 0000000000..2c9eaf5b11 --- /dev/null +++ b/experimental/test/test_cdlp.c.gcov.html @@ -0,0 +1,321 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_cdlp.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_cdlp.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:6161100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //----------------------------------------------------------------------------
+       2             : // LAGraph/src/test/test_cdlp.c: test cases for CDLP
+       3             : // ----------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //-----------------------------------------------------------------------------
+      17             : 
+      18             : // todo: write a simple cdlp method, as LG_check_cdlp, and compare its results
+      19             : // with LAGraph_cdlp
+      20             : 
+      21             : #include <stdio.h>
+      22             : #include <acutest.h>
+      23             : 
+      24             : #include <LAGraphX.h>
+      25             : #include <LAGraph_test.h>
+      26             : 
+      27             : char msg [LAGRAPH_MSG_LEN] ;
+      28             : LAGraph_Graph G = NULL ;
+      29             : GrB_Matrix A = NULL ;
+      30             : #define LEN 512
+      31             : char filename [LEN+1] ;
+      32             : 
+      33             : typedef struct
+      34             : {
+      35             :     bool symmetric ;
+      36             :     const char *name ;
+      37             : }
+      38             : matrix_info ;
+      39             : 
+      40             : double cdlp_jagmesh7 [1138] = {
+      41             :     0, 0, 0, 2, 2, 2, 2, 2, 8, 8, 8, 8, 8, 8, 14, 14, 0, 0, 0, 2, 2, 2, 14,
+      42             :     2, 8, 14, 8, 8, 0, 0, 29, 29, 29, 29, 29, 35, 35, 35, 2, 0, 29, 29, 29,
+      43             :     2, 2, 35, 2, 35, 2, 0, 50, 50, 50, 50, 50, 50, 56, 56, 56, 29, 0, 50, 50,
+      44             :     50, 29, 29, 56, 29, 56, 29, 50, 71, 71, 71, 71, 71, 71, 77, 77, 77, 29,
+      45             :     56, 71, 71, 71, 56, 56, 77, 56, 77, 56, 50, 92, 92, 92, 92, 96, 92, 98,
+      46             :     98, 98, 71, 50, 92, 92, 92, 71, 71, 98, 71, 98, 71, 96, 113, 113, 113,
+      47             :     113, 113, 113, 119, 119, 119, 74, 98, 113, 113, 113, 98, 98, 119, 98, 119,
+      48             :     98, 96, 96, 134, 134, 134, 134, 134, 140, 140, 140, 113, 96, 134, 134, 134,
+      49             :     113, 113, 140, 113, 140, 113, 96, 155, 155, 155, 155, 155, 155, 161, 161,
+      50             :     161, 134, 96, 155, 155, 155, 134, 134, 161, 134, 161, 134, 155, 176, 176,
+      51             :     176, 176, 176, 176, 182, 182, 182, 134, 161, 176, 176, 176, 161, 161, 182,
+      52             :     161, 182, 161, 155, 197, 197, 197, 197, 197, 197, 203, 203, 203, 176, 155,
+      53             :     197, 197, 197, 176, 176, 203, 176, 203, 176, 197, 218, 218, 218, 218, 222,
+      54             :     218, 224, 224, 224, 176, 203, 218, 218, 218, 203, 203, 224, 203, 224, 203,
+      55             :     222, 239, 239, 239, 239, 239, 239, 245, 245, 180, 180, 224, 239, 239, 239,
+      56             :     224, 224, 245, 224, 245, 180, 222, 222, 260, 260, 260, 260, 260, 266, 266,
+      57             :     266, 239, 222, 260, 260, 260, 239, 239, 266, 239, 266, 239, 222, 281, 281,
+      58             :     281, 281, 281, 281, 287, 287, 287, 260, 222, 281, 281, 281, 260, 260, 287,
+      59             :     260, 287, 260, 281, 302, 302, 302, 302, 302, 302, 308, 308, 308, 260, 287,
+      60             :     302, 302, 302, 287, 287, 308, 287, 308, 287, 302, 323, 323, 323, 323, 323,
+      61             :     323, 329, 329, 260, 260, 260, 308, 308, 308, 329, 308, 323, 329, 323, 323,
+      62             :     302, 344, 344, 344, 344, 344, 344, 350, 350, 350, 323, 302, 344, 344, 344,
+      63             :     323, 323, 350, 323, 350, 323, 239, 365, 365, 365, 365, 365, 365, 371, 371,
+      64             :     180, 180, 180, 245, 245, 245, 371, 245, 365, 371, 365, 365, 260, 386, 386,
+      65             :     386, 386, 386, 386, 392, 392, 392, 239, 266, 386, 386, 386, 266, 266, 392,
+      66             :     266, 392, 266, 239, 407, 407, 407, 407, 407, 407, 413, 413, 413, 365, 239,
+      67             :     407, 407, 407, 365, 365, 413, 365, 413, 365, 386, 428, 428, 428, 407, 239,
+      68             :     392, 392, 392, 407, 392, 428, 407, 428, 407, 344, 443, 443, 443, 443, 443,
+      69             :     443, 449, 449, 449, 323, 350, 350, 350, 350, 449, 350, 443, 449, 443, 443,
+      70             :     344, 464, 464, 464, 464, 464, 464, 470, 470, 470, 443, 344, 464, 464, 464,
+      71             :     443, 443, 470, 443, 470, 443, 464, 485, 485, 485, 485, 485, 485, 491, 491,
+      72             :     491, 443, 470, 470, 470, 470, 491, 470, 485, 491, 485, 485, 464, 506, 506,
+      73             :     506, 506, 506, 506, 512, 512, 512, 485, 485, 485, 485, 464, 512, 485, 506,
+      74             :     512, 506, 506, 506, 527, 527, 527, 527, 531, 527, 533, 533, 533, 485, 512,
+      75             :     512, 512, 512, 533, 512, 527, 533, 527, 527, 547, 547, 547, 533, 533, 485,
+      76             :     531, 554, 554, 547, 547, 547, 533, 533, 533, 554, 533, 533, 554, 533, 533,
+      77             :     386, 569, 569, 547, 547, 547, 574, 574, 574, 407, 386, 569, 569, 547, 428,
+      78             :     428, 574, 428, 574, 428, 531, 531, 589, 411, 411, 411, 574, 574, 547, 589,
+      79             :     554, 554, 589, 554, 531, 531, 531, 604, 604, 604, 604, 604, 610, 610, 411,
+      80             :     411, 411, 589, 589, 531, 610, 589, 604, 610, 604, 604, 531, 625, 625, 625,
+      81             :     625, 625, 625, 631, 631, 631, 604, 604, 604, 604, 531, 631, 604, 625, 631,
+      82             :     625, 625, 625, 646, 646, 646, 646, 646, 646, 652, 652, 652, 604, 631, 631,
+      83             :     631, 631, 652, 631, 646, 652, 646, 646, 666, 666, 666, 652, 652, 604, 646,
+      84             :     673, 673, 666, 666, 666, 652, 652, 652, 673, 652, 652, 673, 652, 652, 646,
+      85             :     688, 688, 688, 688, 692, 688, 694, 694, 666, 666, 666, 673, 673, 646, 694,
+      86             :     673, 688, 694, 688, 688, 708, 708, 708, 694, 666, 666, 692, 715, 715, 708,
+      87             :     708, 708, 694, 694, 666, 715, 694, 694, 715, 694, 694, 729, 729, 729, 715,
+      88             :     708, 708, 692, 692, 736, 729, 729, 729, 715, 715, 708, 736, 715, 715, 736,
+      89             :     715, 692, 729, 729, 751, 751, 751, 751, 751, 757, 757, 708, 708, 729, 751,
+      90             :     751, 751, 731, 731, 757, 731, 757, 708, 771, 771, 771, 773, 773, 751, 729,
+      91             :     729, 778, 771, 771, 771, 751, 751, 751, 778, 751, 751, 778, 751, 729, 771,
+      92             :     771, 793, 793, 793, 793, 793, 799, 799, 799, 751, 771, 793, 793, 793, 773,
+      93             :     773, 799, 773, 799, 773, 113, 814, 814, 814, 793, 771, 819, 819, 113, 113,
+      94             :     113, 814, 793, 793, 819, 793, 793, 819, 793, 771, 134, 834, 834, 834, 793,
+      95             :     140, 140, 140, 140, 814, 140, 834, 814, 834, 814, 113, 849, 849, 849, 849,
+      96             :     849, 849, 855, 855, 855, 74, 74, 119, 119, 119, 855, 119, 849, 855, 849,
+      97             :     849, 849, 870, 870, 29, 29, 29, 77, 77, 77, 870, 77, 855, 870, 855, 855, 2,
+      98             :     885, 885, 885, 885, 889, 885, 891, 891, 891, 8, 8, 8, 8, 8, 891, 8, 885,
+      99             :     891, 885, 885, 889, 906, 906, 906, 906, 906, 906, 912, 912, 912, 8, 891,
+     100             :     891, 891, 891, 912, 891, 906, 912, 906, 906, 889, 889, 927, 927, 927, 927,
+     101             :     927, 933, 933, 933, 906, 889, 927, 927, 927, 906, 906, 933, 906, 933, 906,
+     102             :     889, 948, 948, 948, 948, 948, 948, 954, 954, 954, 927, 889, 948, 948, 948,
+     103             :     927, 927, 954, 927, 954, 927, 927, 969, 969, 969, 969, 969, 969, 975, 975,
+     104             :     975, 906, 933, 933, 933, 933, 975, 933, 969, 975, 969, 969, 948, 990, 990,
+     105             :     990, 990, 994, 990, 996, 996, 996, 927, 954, 990, 990, 990, 954, 954, 996,
+     106             :     954, 996, 954, 927, 1011, 1011, 1011, 1011, 1011, 1011, 1017, 1017, 1017,
+     107             :     969, 927, 1011, 1011, 1011, 969, 969, 1017, 969, 1017, 969, 994, 1032,
+     108             :     1032, 1032, 1011, 927, 996, 996, 996, 1011, 996, 1032, 1011, 1032, 1011,
+     109             :     994, 994, 1047, 1047, 1047, 1047, 1047, 1053, 1053, 1053, 1011, 1032, 1032,
+     110             :     1032, 994, 1053, 1032, 1047, 1053, 1047, 1047, 994, 1068, 1068, 1068, 1068,
+     111             :     1068, 1068, 1074, 1074, 1074, 1047, 994, 1068, 1068, 1068, 1047, 1047,
+     112             :     1074, 1047, 1074, 1047, 1068, 1089, 1089, 729, 729, 729, 1094, 1094, 1094,
+     113             :     1047, 1074, 1089, 1089, 729, 1074, 1074, 1094, 1074, 1094, 1074, 1068,
+     114             :     1109, 1109, 771, 771, 1068, 1109, 1109, 771, 1089, 778, 778, 1089, 778,
+     115             :     729, 692, 1124, 1124, 1047, 1047, 729, 736, 736, 692, 1094, 736, 1124,
+     116             :     1094, 1124, 1047 } ;
+     117             : 
+     118             : const matrix_info files [ ] =
+     119             : {
+     120             :     { 1, "A.mtx" },
+     121             :     { 1, "jagmesh7.mtx" },
+     122             :     { 0, "west0067.mtx" }, // unsymmetric
+     123             :     { 1, "bcsstk13.mtx" },
+     124             :     { 1, "karate.mtx" },
+     125             :     { 1, "ldbc-cdlp-undirected-example.mtx" },
+     126             :     { 1, "ldbc-undirected-example-bool.mtx" },
+     127             :     { 1, "ldbc-undirected-example-unweighted.mtx" },
+     128             :     { 1, "ldbc-undirected-example.mtx" },
+     129             :     { 1, "ldbc-wcc-example.mtx" },
+     130             :     { 0, "" },
+     131             : } ;
+     132             : 
+     133             : //****************************************************************************
+     134           1 : void test_cdlp (void)
+     135             : {
+     136           1 :     LAGraph_Init (msg) ;
+     137             : 
+     138           1 :     for (int k = 0 ; ; k++)
+     139          10 :     {
+     140             : 
+     141             :         // load the matrix as A
+     142          11 :         const char *aname = files [k].name ;
+     143          11 :         bool symmetric = files [k].symmetric ;
+     144          11 :         if (strlen (aname) == 0) break;
+     145          10 :         printf ("\n================================== %s:\n", aname) ;
+     146          10 :         TEST_CASE (aname) ;
+     147          10 :         snprintf (filename, LEN, LG_DATA_DIR "%s", aname) ;
+     148          10 :         FILE *f = fopen (filename, "r") ;
+     149          10 :         TEST_CHECK (f != NULL) ;
+     150          10 :         OK (LAGraph_MMRead (&A, f, msg)) ;
+     151             : 
+     152             :         // construct a directed graph G with adjacency matrix A
+     153          10 :         OK (LAGraph_New (&G, &A, LAGraph_ADJACENCY_DIRECTED, msg)) ;
+     154          10 :         TEST_CHECK (A == NULL) ;
+     155             : 
+     156             :         // check for self-edges
+     157          10 :         OK (LAGraph_Cached_NSelfEdges (G, msg)) ;
+     158          10 :         bool sanitize = (G->nself_edges != 0) ;
+     159             : 
+     160          10 :         GrB_Vector c = NULL ;
+     161             :         double t [2] ;
+     162             : 
+     163             :         // compute the communities with LAGraph_cdlp
+     164          10 :         OK (LAGraph_cdlp (&c, G->A, symmetric, sanitize, 100, t, msg)) ;
+     165             : 
+     166             :         GrB_Index n ;
+     167          10 :         OK (GrB_Vector_size (&n, c)) ;
+     168          10 :         LAGraph_PrintLevel pr = (n <= 100) ? LAGraph_COMPLETE : LAGraph_SHORT ;
+     169             : 
+     170             :         // check result c for jagmesh7
+     171          10 :         if (strcmp (aname, "jagmesh7.mtx") == 0)
+     172             :         {
+     173           1 :             GrB_Vector cgood = NULL ;
+     174           1 :             OK (GrB_Vector_new (&cgood, GrB_UINT64, n)) ;
+     175        1139 :             for (int k = 0 ; k < n ; k++)
+     176             :             {
+     177        1138 :                 OK (GrB_Vector_setElement (cgood, cdlp_jagmesh7 [k], k)) ;
+     178             :             }
+     179           1 :             OK (GrB_wait (cgood, GrB_MATERIALIZE)) ;
+     180           1 :             printf ("\ncdlp (known result):\n") ;
+     181           1 :             OK (LAGraph_Vector_Print (cgood, pr, stdout, msg)) ;
+     182           1 :             bool ok = false ;
+     183           1 :             OK (LAGraph_Vector_IsEqual (&ok, c, cgood, msg)) ;
+     184           1 :             TEST_CHECK (ok) ;
+     185           1 :             OK (GrB_free (&cgood)) ;
+     186             :         }
+     187             : 
+     188          10 :         printf ("\ncdlp:\n") ;
+     189          10 :         OK (LAGraph_Vector_Print (c, pr, stdout, msg)) ;
+     190          10 :         OK (GrB_free (&c)) ;
+     191             : 
+     192          10 :         OK (LAGraph_Delete (&G, msg)) ;
+     193             :     }
+     194             : 
+     195           1 :     LAGraph_Finalize (msg) ;
+     196           1 : }
+     197             : 
+     198             : //------------------------------------------------------------------------------
+     199             : // test_errors
+     200             : //------------------------------------------------------------------------------
+     201             : 
+     202           1 : void test_errors (void)
+     203             : {
+     204           1 :     LAGraph_Init (msg) ;
+     205             : 
+     206           1 :     snprintf (filename, LEN, LG_DATA_DIR "%s", "karate.mtx") ;
+     207           1 :     FILE *f = fopen (filename, "r") ;
+     208           1 :     TEST_CHECK (f != NULL) ;
+     209           1 :     OK (LAGraph_MMRead (&A, f, msg)) ;
+     210           1 :     TEST_MSG ("Loading of adjacency matrix failed") ;
+     211             : 
+     212             :     // construct an undirected graph G with adjacency matrix A
+     213           1 :     OK (LAGraph_New (&G, &A, LAGraph_ADJACENCY_UNDIRECTED, msg)) ;
+     214           1 :     TEST_CHECK (A == NULL) ;
+     215             : 
+     216           1 :     OK (LAGraph_Cached_NSelfEdges (G, msg)) ;
+     217             : 
+     218           1 :     GrB_Vector c = NULL ;
+     219             :     double t [2] ;
+     220             : 
+     221             :     // c is NULL
+     222           1 :     int result = LAGraph_cdlp (NULL, G->A, true, false, 100, t, msg) ;
+     223           1 :     printf ("\nresult: %d\n", result) ;
+     224           1 :     TEST_CHECK (result == GrB_NULL_POINTER) ;
+     225             : 
+     226             :     #if LAGRAPH_SUITESPARSE
+     227             :     // G->A is held by column
+     228           1 :     OK (GxB_set (G->A, GxB_FORMAT, GxB_BY_COL)) ;
+     229           1 :     result = LAGraph_cdlp (&c, G->A, true, true, 100, t, msg) ;
+     230           1 :     printf ("\nresult: %d\n", result) ;
+     231           1 :     TEST_CHECK (result == GrB_INVALID_VALUE) ;
+     232           1 :     TEST_CHECK (c == NULL) ;
+     233             :     #endif
+     234             : 
+     235           1 :     OK (LAGraph_Delete (&G, msg)) ;
+     236           1 :     LAGraph_Finalize (msg) ;
+     237           1 : }
+     238             : 
+     239             : //****************************************************************************
+     240             : 
+     241             : TEST_LIST = {
+     242             :     {"cdlp", test_cdlp},
+     243             :     {"cdlp_errors", test_errors},
+     244             :     {NULL, NULL}
+     245             : };
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_dnn.c.func-sort-c.html b/experimental/test/test_dnn.c.func-sort-c.html new file mode 100644 index 0000000000..ee01c23f08 --- /dev/null +++ b/experimental/test/test_dnn.c.func-sort-c.html @@ -0,0 +1,84 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_dnn.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_dnn.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:7373100.0 %
Date:2024-08-29 20:08:04Functions:33100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
setup1
teardown1
test_dnn1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_dnn.c.func.html b/experimental/test/test_dnn.c.func.html new file mode 100644 index 0000000000..ae0823b5a5 --- /dev/null +++ b/experimental/test/test_dnn.c.func.html @@ -0,0 +1,84 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_dnn.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_dnn.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:7373100.0 %
Date:2024-08-29 20:08:04Functions:33100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
setup1
teardown1
test_dnn1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_dnn.c.gcov.html b/experimental/test/test_dnn.c.gcov.html new file mode 100644 index 0000000000..da776146d7 --- /dev/null +++ b/experimental/test/test_dnn.c.gcov.html @@ -0,0 +1,278 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_dnn.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_dnn.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:7373100.0 %
Date:2024-08-29 20:08:04Functions:33100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph/experimental/test/test_dnn: test a small sparse deep neural network
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include <stdio.h>
+      19             : #include <acutest.h>
+      20             : #include "LAGraphX.h"
+      21             : #include "LAGraph_test.h"
+      22             : #include "LG_Xtest.h"
+      23             : #include "LG_internal.h"
+      24             : 
+      25             : char msg [LAGRAPH_MSG_LEN] ;
+      26             : 
+      27             : //------------------------------------------------------------------------------
+      28             : // setup: start a test
+      29             : //------------------------------------------------------------------------------
+      30             : 
+      31           1 : void setup (void)
+      32             : {
+      33           1 :     OK (LAGraph_Init (msg)) ;
+      34           1 :     OK (LAGraph_Random_Init (msg)) ;
+      35           1 : }
+      36             : 
+      37             : //------------------------------------------------------------------------------
+      38             : // teardown: finalize a test
+      39             : //------------------------------------------------------------------------------
+      40             : 
+      41           1 : void teardown (void)
+      42             : {
+      43           1 :     OK (LAGraph_Random_Finalize (msg)) ;
+      44           1 :     OK (LAGraph_Finalize (msg)) ;
+      45           1 : }
+      46             : 
+      47             : //------------------------------------------------------------------------------
+      48             : // test_dnn: test a small DNN from https://graphchallenge.mit.edu/data-sets
+      49             : //------------------------------------------------------------------------------
+      50             : 
+      51             : // This test uses the smallest sparse deep neural network at
+      52             : // https://graphchallenge.mit.edu/data-sets .  The original problem has 120
+      53             : // layers, but the categories converge to the correct result in the first 27
+      54             : // layers, so only the first 32 layers are included in this test.
+      55             : 
+      56             : // The original problem also hase 60,000 features (images) but in this
+      57             : // truncated problem, only the first 2000 features are used.
+      58             : 
+      59           1 : void test_dnn (void)
+      60             : {
+      61             :     GrB_Info info ;
+      62           1 :     setup ( ) ;
+      63             : 
+      64             :     #define NLAYERS 30
+      65             :     #define NLAYERS_ORIG 120
+      66           1 :     int nlayers = NLAYERS ;
+      67           1 :     float bias = -0.3 ;
+      68           1 :     int nneurons = 1024 ;
+      69           1 :     int nfeatures = 60000 ;
+      70           1 :     int nfeatures_subset = 1200 ;
+      71             : 
+      72           1 :     printf ("\nSparse deep neural network from"
+      73             :         " https://graphchallenge.mit.edu/data-sets\n"
+      74             :         "# neurons: %d, bias: %g\n"
+      75             :         "original # of layers: %d, layers used here: %d\n"
+      76             :         "original # of features: %d, features used here: %d\n",
+      77             :         nneurons, bias, NLAYERS_ORIG, nlayers, nfeatures, nfeatures_subset) ;
+      78             : 
+      79           1 :     GrB_Matrix Y0 = NULL, Y = NULL, W [NLAYERS], Bias [NLAYERS], T = NULL ;
+      80           1 :     GrB_Vector TrueCategories = NULL, Categories = NULL, C = NULL ;
+      81          31 :     for (int layer = 0 ; layer < nlayers ; layer++)
+      82             :     {
+      83          30 :         W [layer] = NULL ;
+      84          30 :         Bias [layer] = NULL ;
+      85             :     }
+      86             : 
+      87             :     #define LEN 512
+      88             :     char filename [LEN] ;
+      89             : 
+      90             :     //--------------------------------------------------------------------------
+      91             :     // read in the problem
+      92             :     //--------------------------------------------------------------------------
+      93             : 
+      94           1 :     snprintf (filename, LEN, LG_DATA_DIR
+      95             :         "/dnn_data/sparse-images-%d_subset.mtx", nneurons) ;
+      96           1 :     FILE *f = fopen (filename, "r") ;
+      97           1 :     TEST_CHECK (f != NULL) ;
+      98           1 :     OK (LAGraph_MMRead (&Y0, f, msg)) ;
+      99           1 :     fclose (f) ;
+     100             :     char type_name [LAGRAPH_MAX_NAME_LEN] ;
+     101           1 :     OK (LAGraph_Matrix_TypeName (type_name, Y0, msg)) ;
+     102           1 :     TEST_CHECK (MATCHNAME (type_name, "float")) ;
+     103           1 :     OK (GrB_wait (Y0, GrB_MATERIALIZE)) ;
+     104             : 
+     105          31 :     for (int layer = 0 ; layer < nlayers ; layer++)
+     106             :     {
+     107             :         // read the neuron layer: W [layer]
+     108          30 :         snprintf (filename, LEN, LG_DATA_DIR "/dnn_data/n%d-l%d.mtx",
+     109             :             nneurons, layer+1) ;
+     110          30 :         f = fopen (filename, "r") ;
+     111          30 :         TEST_CHECK (f != NULL) ;
+     112          30 :         OK (LAGraph_MMRead (&(W [layer]), f, msg)) ;
+     113          30 :         fclose (f) ;
+     114          30 :         OK (LAGraph_Matrix_TypeName (type_name, W [layer], msg)) ;
+     115          30 :         TEST_CHECK (MATCHNAME (type_name, "float")) ;
+     116             : 
+     117             :         // construct the bias matrix: Bias [layer].  Note that all Bias
+     118             :         // matrices are the same for all layers, and all diagonal
+     119             :         // entries are also the same.
+     120          30 :         OK (GrB_Matrix_new (&(Bias [layer]), GrB_FP32, nneurons, nneurons)) ;
+     121       30750 :         for (int i = 0 ; i < nneurons ; i++)
+     122             :         {
+     123       30720 :             OK (GrB_Matrix_setElement (Bias [layer], bias, i, i)) ;
+     124             :         }
+     125          30 :         OK (GrB_wait (Bias [layer], GrB_MATERIALIZE)) ;
+     126             :     }
+     127             : 
+     128             :     // read T as a boolean nfeatures_subset-by-1 matrix
+     129           1 :     snprintf (filename, LEN, LG_DATA_DIR
+     130             :         "/dnn_data/neuron%d-l%d-categories_subset.mtx",
+     131             :         nneurons, NLAYERS_ORIG) ;
+     132           1 :     f = fopen (filename, "r") ;
+     133           1 :     TEST_CHECK (f != NULL) ;
+     134           1 :     OK (LAGraph_MMRead (&T, f, msg)) ;
+     135           1 :     OK (LAGraph_Matrix_TypeName (type_name, T, msg)) ;
+     136           1 :     TEST_CHECK (MATCHNAME (type_name, "bool")) ;
+     137             :     // TrueCategories = T, as a boolean nfeatures-by-1 vector
+     138           1 :     printf ("\nTrue categories:\n") ;
+     139           1 :     OK (GrB_Vector_new (&TrueCategories, GrB_BOOL, nfeatures_subset)) ;
+     140           1 :     OK (GrB_Col_extract (TrueCategories, NULL, NULL, T, GrB_ALL,
+     141             :         nfeatures_subset, 0, NULL)) ;
+     142           1 :     OK (LAGraph_Vector_Print (TrueCategories, LAGraph_COMPLETE, stdout, msg)) ;
+     143           1 :     GrB_free (&T) ;
+     144             : 
+     145             :     //--------------------------------------------------------------------------
+     146             :     // solve the problem
+     147             :     //--------------------------------------------------------------------------
+     148             : 
+     149           1 :     OK (LAGraph_dnn (&Y, W, Bias, nlayers, Y0)) ;
+     150             : 
+     151             :     //--------------------------------------------------------------------------
+     152             :     // check the result
+     153             :     //--------------------------------------------------------------------------
+     154             : 
+     155             :     // C = sum (Y)
+     156           1 :     OK (GrB_Vector_new (&C, GrB_FP32, nfeatures_subset)) ;
+     157           1 :     OK (GrB_reduce (C, NULL, NULL, GrB_PLUS_FP32, Y, NULL));
+     158             :     // Categories = pattern of C
+     159           1 :     OK (GrB_Vector_new (&Categories, GrB_BOOL, nfeatures_subset)) ;
+     160           1 :     OK (GrB_apply (Categories, NULL, NULL, GrB_ONEB_BOOL, C, (bool) true,
+     161             :         NULL)) ;
+     162             : 
+     163             :     // check if Categories and TrueCategories are the same
+     164             :     bool isequal ;
+     165           1 :     printf ("\nComputed categories:\n") ;
+     166           1 :     OK (LAGraph_Vector_Print (Categories, LAGraph_COMPLETE, stdout, msg)) ;
+     167           1 :     OK (LAGraph_Vector_IsEqual (&isequal, TrueCategories, Categories, NULL)) ;
+     168           1 :     TEST_CHECK (isequal) ;
+     169             : 
+     170             :     //--------------------------------------------------------------------------
+     171             :     // free everything and finish the test
+     172             :     //--------------------------------------------------------------------------
+     173             : 
+     174           1 :     GrB_free (&TrueCategories) ;
+     175           1 :     GrB_free (&Categories) ;
+     176           1 :     GrB_free (&C) ;
+     177           1 :     GrB_free (&Y) ;
+     178           1 :     GrB_free (&Y0) ;
+     179          31 :     for (int layer = 0 ; layer < nlayers ; layer++)
+     180             :     {
+     181          30 :         GrB_free (& (W [layer])) ;
+     182          30 :         GrB_free (& (Bias [layer])) ;
+     183             :     }
+     184             : 
+     185             :     //--------------------------------------------------------------------------
+     186             :     // error tests
+     187             :     //--------------------------------------------------------------------------
+     188             : 
+     189           1 :     int result = LAGraph_dnn (NULL, NULL, NULL, nlayers, NULL) ;
+     190           1 :     TEST_CHECK (result == GrB_NULL_POINTER) ;
+     191             : 
+     192           1 :     teardown ( ) ;
+     193           1 : }
+     194             : 
+     195             : //------------------------------------------------------------------------------
+     196             : // TEST_LIST: all tests to run
+     197             : //------------------------------------------------------------------------------
+     198             : 
+     199             : TEST_LIST = {
+     200             :     {"DNN", test_dnn},
+     201             :     {NULL, NULL}
+     202             : } ;
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_lcc.c.func-sort-c.html b/experimental/test/test_lcc.c.func-sort-c.html new file mode 100644 index 0000000000..f335fb69f7 --- /dev/null +++ b/experimental/test/test_lcc.c.func-sort-c.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_lcc.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_lcc.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:6464100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_errors1
test_lcc1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_lcc.c.func.html b/experimental/test/test_lcc.c.func.html new file mode 100644 index 0000000000..95e5a0def5 --- /dev/null +++ b/experimental/test/test_lcc.c.func.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_lcc.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_lcc.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:6464100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_errors1
test_lcc1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_lcc.c.gcov.html b/experimental/test/test_lcc.c.gcov.html new file mode 100644 index 0000000000..5cb49cd8dc --- /dev/null +++ b/experimental/test/test_lcc.c.gcov.html @@ -0,0 +1,326 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_lcc.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_lcc.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:6464100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //----------------------------------------------------------------------------
+       2             : // LAGraph/experimental/test/test_lcc.c: tests for Local Clustering Coefficient
+       3             : // ----------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //-----------------------------------------------------------------------------
+      17             : 
+      18             : // todo: write a simple lcc method, as LG_check_lcc, and compare its results
+      19             : // with LAGraph_lcc
+      20             : 
+      21             : #include <stdio.h>
+      22             : #include <acutest.h>
+      23             : 
+      24             : #include <LAGraphX.h>
+      25             : #include <LAGraph_test.h>
+      26             : 
+      27             : char msg [LAGRAPH_MSG_LEN] ;
+      28             : LAGraph_Graph G = NULL ;
+      29             : GrB_Matrix A = NULL ;
+      30             : #define LEN 512
+      31             : char filename [LEN+1] ;
+      32             : 
+      33             : typedef struct
+      34             : {
+      35             :     bool symmetric ;
+      36             :     const char *name ;
+      37             : }
+      38             : matrix_info ;
+      39             : 
+      40             : // this known solution is listed here in lower precision than double allows
+      41             : double lcc_west0067 [67] = {
+      42             :     0.0909091,
+      43             :     0.0238095,
+      44             :     0.0714286,
+      45             :     0.0238095,
+      46             :     0.125,
+      47             :     0.119048,
+      48             :     0.178571,
+      49             :     0.133333,
+      50             :     0.0952381,
+      51             :     0.0833333,
+      52             :     0.0666667,
+      53             :     0.1,
+      54             :     0.0892857,
+      55             :     0.0714286,
+      56             :     0.138889,
+      57             :     0.0555556,
+      58             :     0.0694444,
+      59             :     0.0555556,
+      60             :     0.0714286,
+      61             :     0.0769231,
+      62             :     0.0333333,
+      63             :     0.0666667,
+      64             :     0.0666667,
+      65             :     0.0333333,
+      66             :     0.0694444,
+      67             :     0.0444444,
+      68             :     0.0555556,
+      69             :     0.0777778,
+      70             :     0.0333333,
+      71             :             0,
+      72             :     0.0904762,
+      73             :     0.0535714,
+      74             :     0.0714286,
+      75             :     0.107143,
+      76             :     0.0892857,
+      77             :             0,
+      78             :     0.0681818,
+      79             :     0.0357143,
+      80             :     0.0178571,
+      81             :     0.0666667,
+      82             :     0.0555556,
+      83             :     0.0694444,
+      84             :     0.0666667,
+      85             :     0.111111,
+      86             :     0.0444444,
+      87             :     0.142857,
+      88             :     0.166667,
+      89             :     0.2,
+      90             :     0.0448718,
+      91             :     0.166667,
+      92             :     0.166667,
+      93             :     0.119048,
+      94             :     0.166667,
+      95             :     0.190476,
+      96             :     0.104167,
+      97             :     0.0333333,
+      98             :     0.0444444,
+      99             :     0.0444444,
+     100             :     0.0777778,
+     101             :     0.0416667,
+     102             :     0.0222222,
+     103             :     0.0972222,
+     104             :     0.142857,
+     105             :     0.0416667,
+     106             :     0.0555556,
+     107             :     0.196429,
+     108             :     0.155556
+     109             : } ;
+     110             : 
+     111             : const matrix_info files [ ] =
+     112             : {
+     113             :     { 1, "A.mtx" },
+     114             :     { 1, "jagmesh7.mtx" },
+     115             :     { 0, "west0067.mtx" }, // unsymmetric
+     116             :     { 1, "bcsstk13.mtx" },
+     117             :     { 1, "karate.mtx" },
+     118             :     { 1, "ldbc-cdlp-undirected-example.mtx" },
+     119             :     { 1, "ldbc-undirected-example-bool.mtx" },
+     120             :     { 1, "ldbc-undirected-example-unweighted.mtx" },
+     121             :     { 1, "ldbc-undirected-example.mtx" },
+     122             :     { 1, "ldbc-wcc-example.mtx" },
+     123             :     { 0, "" },
+     124             : } ;
+     125             : 
+     126             : //****************************************************************************
+     127           1 : void test_lcc (void)
+     128             : {
+     129           1 :     LAGraph_Init (msg) ;
+     130             :     #if LAGRAPH_SUITESPARSE
+     131             : 
+     132           1 :     for (int k = 0 ; ; k++)
+     133          10 :     {
+     134             : 
+     135             :         // load the matrix as A
+     136          11 :         const char *aname = files [k].name ;
+     137          11 :         bool symmetric = files [k].symmetric ;
+     138          11 :         if (strlen (aname) == 0) break;
+     139          10 :         printf ("\n================================== %s:\n", aname) ;
+     140          10 :         TEST_CASE (aname) ;
+     141          10 :         snprintf (filename, LEN, LG_DATA_DIR "%s", aname) ;
+     142          10 :         FILE *f = fopen (filename, "r") ;
+     143          10 :         TEST_CHECK (f != NULL) ;
+     144          10 :         OK (LAGraph_MMRead (&A, f, msg)) ;
+     145             : 
+     146             :         // construct a directed graph G with adjacency matrix A
+     147          10 :         OK (LAGraph_New (&G, &A, LAGraph_ADJACENCY_DIRECTED, msg)) ;
+     148          10 :         TEST_CHECK (A == NULL) ;
+     149             : 
+     150             :         // check for self-edges
+     151          10 :         OK (LAGraph_Cached_NSelfEdges (G, msg)) ;
+     152          10 :         bool sanitize = (G->nself_edges != 0) ;
+     153             : 
+     154          10 :         GrB_Vector c = NULL ;
+     155             :         double t [2] ;
+     156             : 
+     157             :         // compute the local clustering coefficient
+     158          10 :         OK (LAGraph_lcc (&c, G->A, symmetric, sanitize, t, msg)) ;
+     159             : 
+     160             :         GrB_Index n ;
+     161          10 :         OK (GrB_Vector_size (&n, c)) ;
+     162          10 :         LAGraph_PrintLevel pr = (n <= 100) ? LAGraph_COMPLETE : LAGraph_SHORT ;
+     163             : 
+     164             :         // check result c for west0067
+     165          10 :         if (strcmp (aname, "west0067.mtx") == 0)
+     166             :         {
+     167           1 :             GrB_Vector cgood = NULL ;
+     168           1 :             OK (GrB_Vector_new (&cgood, GrB_FP64, n)) ;
+     169          68 :             for (int k = 0 ; k < n ; k++)
+     170             :             {
+     171          67 :                 OK (GrB_Vector_setElement (cgood, lcc_west0067 [k], k)) ;
+     172             :             }
+     173           1 :             OK (GrB_wait (cgood, GrB_MATERIALIZE)) ;
+     174           1 :             printf ("\nlcc (known result, but with float precision):\n") ;
+     175           1 :             OK (LAGraph_Vector_Print (cgood, pr, stdout, msg)) ;
+     176             :             // cgood = abs (cgood - c)
+     177           1 :             OK (GrB_eWiseAdd (cgood, NULL, NULL, GrB_MINUS_FP64, cgood, c,
+     178             :                 NULL)) ;
+     179           1 :             OK (GrB_apply (cgood, NULL, NULL, GrB_ABS_FP64, cgood, NULL)) ;
+     180           1 :             double err = 0 ;
+     181             :             // err = max (cgood)
+     182           1 :             OK (GrB_reduce (&err, NULL, GrB_MAX_MONOID_FP64, cgood, NULL)) ;
+     183           1 :             printf ("err: %g\n", err) ;
+     184           1 :             TEST_CHECK (err < 1e-6) ;
+     185           1 :             OK (GrB_free (&cgood)) ;
+     186             :         }
+     187             : 
+     188          10 :         printf ("\nlcc:\n") ;
+     189          10 :         OK (LAGraph_Vector_Print (c, pr, stdout, msg)) ;
+     190          10 :         OK (GrB_free (&c)) ;
+     191             : 
+     192          10 :         OK (LAGraph_Delete (&G, msg)) ;
+     193             :     }
+     194             : 
+     195             :     #else
+     196             :     printf ("test skipped\n") ;
+     197             :     #endif
+     198           1 :     LAGraph_Finalize (msg) ;
+     199           1 : }
+     200             : 
+     201             : //------------------------------------------------------------------------------
+     202             : // test_errors
+     203             : //------------------------------------------------------------------------------
+     204             : 
+     205           1 : void test_errors (void)
+     206             : {
+     207           1 :     LAGraph_Init (msg) ;
+     208             :     #if LAGRAPH_SUITESPARSE
+     209             : 
+     210           1 :     snprintf (filename, LEN, LG_DATA_DIR "%s", "karate.mtx") ;
+     211           1 :     FILE *f = fopen (filename, "r") ;
+     212           1 :     TEST_CHECK (f != NULL) ;
+     213           1 :     OK (LAGraph_MMRead (&A, f, msg)) ;
+     214           1 :     TEST_MSG ("Loading of adjacency matrix failed") ;
+     215             : 
+     216             :     // construct an undirected graph G with adjacency matrix A
+     217           1 :     OK (LAGraph_New (&G, &A, LAGraph_ADJACENCY_UNDIRECTED, msg)) ;
+     218           1 :     TEST_CHECK (A == NULL) ;
+     219             : 
+     220           1 :     OK (LAGraph_Cached_NSelfEdges (G, msg)) ;
+     221             : 
+     222           1 :     GrB_Vector c = NULL ;
+     223             :     double t [2] ;
+     224             : 
+     225             :     // c is NULL
+     226           1 :     int result = LAGraph_lcc (NULL, G->A, true, false, t, msg) ;
+     227           1 :     printf ("\nresult: %d\n", result) ;
+     228           1 :     TEST_CHECK (result == GrB_NULL_POINTER) ;
+     229             : 
+     230             :     // G->A is held by column
+     231           1 :     OK (GxB_set (G->A, GxB_FORMAT, GxB_BY_COL)) ;
+     232           1 :     result = LAGraph_lcc (&c, G->A, true, true, t, msg) ;
+     233           1 :     printf ("\nresult: %d\n", result) ;
+     234           1 :     TEST_CHECK (result == GrB_INVALID_VALUE) ;
+     235           1 :     TEST_CHECK (c == NULL) ;
+     236             : 
+     237           1 :     OK (LAGraph_Delete (&G, msg)) ;
+     238             :     #else
+     239             :     printf ("test skipped\n") ;
+     240             :     #endif
+     241           1 :     LAGraph_Finalize (msg) ;
+     242           1 : }
+     243             : 
+     244             : //****************************************************************************
+     245             : 
+     246             : TEST_LIST = {
+     247             :     {"lcc", test_lcc},
+     248             :     {"lcc_errors", test_errors},
+     249             :     {NULL, NULL}
+     250             : };
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_msf.c.func-sort-c.html b/experimental/test/test_msf.c.func-sort-c.html new file mode 100644 index 0000000000..33833b4ab2 --- /dev/null +++ b/experimental/test/test_msf.c.func-sort-c.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_msf.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_msf.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:5858100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_errors1
test_msf1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_msf.c.func.html b/experimental/test/test_msf.c.func.html new file mode 100644 index 0000000000..607794e70b --- /dev/null +++ b/experimental/test/test_msf.c.func.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_msf.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_msf.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:5858100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_errors1
test_msf1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_msf.c.gcov.html b/experimental/test/test_msf.c.gcov.html new file mode 100644 index 0000000000..0651c31912 --- /dev/null +++ b/experimental/test/test_msf.c.gcov.html @@ -0,0 +1,238 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_msf.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_msf.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:5858100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph/experimental/test/test_msf.c: test cases for Min Spanning Forest
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // todo: write a simple msf method, as LG_check_msf, and compare its results
+      19             : // with LAGraph_msf
+      20             : 
+      21             : #include <stdio.h>
+      22             : #include <acutest.h>
+      23             : 
+      24             : #include <LAGraphX.h>
+      25             : #include <LAGraph_test.h>
+      26             : 
+      27             : char msg [LAGRAPH_MSG_LEN] ;
+      28             : LAGraph_Graph G = NULL ;
+      29             : GrB_Matrix A = NULL ;
+      30             : GrB_Matrix S = NULL ;
+      31             : GrB_Matrix C = NULL ;
+      32             : #define LEN 512
+      33             : char filename [LEN+1] ;
+      34             : 
+      35             : typedef struct
+      36             : {
+      37             :     bool symmetric ;
+      38             :     const char *name ;
+      39             : }
+      40             : matrix_info ;
+      41             : 
+      42             : const matrix_info files [ ] =
+      43             : {
+      44             :     { 1, "A.mtx" },
+      45             :     { 1, "jagmesh7.mtx" },
+      46             :     { 0, "west0067.mtx" }, // unsymmetric
+      47             :     { 1, "bcsstk13.mtx" },
+      48             :     { 1, "karate.mtx" },
+      49             :     { 1, "ldbc-cdlp-undirected-example.mtx" },
+      50             :     { 1, "ldbc-undirected-example-bool.mtx" },
+      51             :     { 1, "ldbc-undirected-example-unweighted.mtx" },
+      52             :     { 1, "ldbc-undirected-example.mtx" },
+      53             :     { 1, "ldbc-wcc-example.mtx" },
+      54             :     { 0, "" },
+      55             : } ;
+      56             : 
+      57             : //****************************************************************************
+      58           1 : void test_msf (void)
+      59             : {
+      60           1 :     LAGraph_Init (msg) ;
+      61             :     #if LAGRAPH_SUITESPARSE
+      62             : 
+      63           1 :     for (int k = 0 ; ; k++)
+      64          10 :     {
+      65             : 
+      66             :         // load the matrix as A
+      67          11 :         const char *aname = files [k].name ;
+      68          11 :         bool symmetric = files [k].symmetric ;
+      69          11 :         if (strlen (aname) == 0) break;
+      70          10 :         printf ("\n================================== %s:\n", aname) ;
+      71          10 :         TEST_CASE (aname) ;
+      72          10 :         snprintf (filename, LEN, LG_DATA_DIR "%s", aname) ;
+      73          10 :         FILE *f = fopen (filename, "r") ;
+      74          10 :         TEST_CHECK (f != NULL) ;
+      75          10 :         OK (LAGraph_MMRead (&A, f, msg)) ;
+      76             : 
+      77             :         // ensure A is uint64
+      78             :         GrB_Index nrows, ncols ;
+      79          10 :         OK (GrB_Matrix_nrows (&nrows, A)) ;
+      80          10 :         OK (GrB_Matrix_ncols (&ncols, A)) ;
+      81          10 :         OK (GrB_Matrix_new (&S, GrB_UINT64, nrows, ncols)) ;
+      82          10 :         OK (GrB_assign (S, NULL, NULL, A, GrB_ALL, nrows, GrB_ALL, ncols,
+      83             :             NULL)) ;
+      84          10 :         GrB_Index n = nrows ;
+      85          10 :         OK (GrB_free (&A)) ;
+      86             : 
+      87             :         // construct a directed graph G with adjacency matrix S
+      88          10 :         OK (LAGraph_New (&G, &S, LAGraph_ADJACENCY_DIRECTED, msg)) ;
+      89          10 :         TEST_CHECK (S == NULL) ;
+      90             : 
+      91          10 :         bool sanitize = (!symmetric) ;
+      92             : 
+      93             :         // compute the min spanning forest
+      94          10 :         C = NULL ;
+      95          10 :         int result = LAGraph_msf (&C, G->A, sanitize, msg) ;
+      96          10 :         printf ("result: %d\n", result) ;
+      97          10 :         LAGraph_PrintLevel pr = (n <= 100) ? LAGraph_COMPLETE : LAGraph_SHORT ;
+      98             : 
+      99             :         // check result C for A.mtx
+     100          10 :         if (strcmp (aname, "A.mtx") == 0)
+     101             :         {
+     102           1 :             GrB_Matrix Cgood = NULL ;
+     103           1 :             OK (GrB_Matrix_new (&Cgood, GrB_UINT64, n, n)) ;
+     104           1 :             OK (GrB_Matrix_setElement (Cgood, 1, 1, 0)) ;
+     105           1 :             OK (GrB_Matrix_setElement (Cgood, 1, 2, 0)) ;
+     106           1 :             OK (GrB_Matrix_setElement (Cgood, 1, 3, 1)) ;
+     107           1 :             OK (GrB_Matrix_setElement (Cgood, 1, 4, 1)) ;
+     108           1 :             OK (GrB_Matrix_setElement (Cgood, 1, 5, 1)) ;
+     109           1 :             OK (GrB_Matrix_setElement (Cgood, 1, 6, 0)) ;
+     110           1 :             OK (GrB_wait (Cgood, GrB_MATERIALIZE)) ;
+     111           1 :             printf ("\nmsf (known result):\n") ;
+     112           1 :             OK (LAGraph_Matrix_Print (Cgood, pr, stdout, msg)) ;
+     113           1 :             bool ok = false ;
+     114           1 :             OK (LAGraph_Matrix_IsEqual (&ok, C, Cgood, msg)) ;
+     115           1 :             TEST_CHECK (ok) ;
+     116           1 :             OK (GrB_free (&Cgood)) ;
+     117             :         }
+     118             : 
+     119          10 :         printf ("\nmsf:\n") ;
+     120          10 :         OK (LAGraph_Matrix_Print (C, pr, stdout, msg)) ;
+     121          10 :         OK (GrB_free (&C)) ;
+     122          10 :         OK (LAGraph_Delete (&G, msg)) ;
+     123             :     }
+     124             : 
+     125             :     #else
+     126             :     printf ("test skipped\n") ;
+     127             :     #endif
+     128           1 :     LAGraph_Finalize (msg) ;
+     129           1 : }
+     130             : 
+     131             : //------------------------------------------------------------------------------
+     132             : // test_errors
+     133             : //------------------------------------------------------------------------------
+     134             : 
+     135           1 : void test_errors (void)
+     136             : {
+     137           1 :     LAGraph_Init (msg) ;
+     138             :     #if LAGRAPH_SUITESPARSE
+     139             : 
+     140             :     // C and A are NULL
+     141           1 :     int result = LAGraph_msf (NULL, NULL, true, msg) ;
+     142           1 :     TEST_CHECK (result == GrB_NULL_POINTER) ;
+     143             : 
+     144             :     // A must be square
+     145           1 :     OK (GrB_Matrix_new (&A, GrB_UINT64, 3, 4)) ;
+     146           1 :     result = LAGraph_msf (&C, A, true, msg) ;
+     147           1 :     TEST_CHECK (result == GrB_DIMENSION_MISMATCH) ;
+     148             : 
+     149           1 :     OK (GrB_free (&A)) ;
+     150             :     #else
+     151             :     printf ("test skipped\n") ;
+     152             :     #endif
+     153           1 :     LAGraph_Finalize (msg) ;
+     154           1 : }
+     155             : 
+     156             : //****************************************************************************
+     157             : 
+     158             : TEST_LIST = {
+     159             :     {"msf", test_msf},
+     160             :     {"msf_errors", test_errors},
+     161             :     {NULL, NULL}
+     162             : };
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_scc.c.func-sort-c.html b/experimental/test/test_scc.c.func-sort-c.html new file mode 100644 index 0000000000..621cc4debd --- /dev/null +++ b/experimental/test/test_scc.c.func-sort-c.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_scc.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_scc.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:5050100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_errors1
test_scc1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_scc.c.func.html b/experimental/test/test_scc.c.func.html new file mode 100644 index 0000000000..2b407be9a3 --- /dev/null +++ b/experimental/test/test_scc.c.func.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_scc.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_scc.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:5050100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_errors1
test_scc1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/test/test_scc.c.gcov.html b/experimental/test/test_scc.c.gcov.html new file mode 100644 index 0000000000..07e95b4884 --- /dev/null +++ b/experimental/test/test_scc.c.gcov.html @@ -0,0 +1,271 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/test/test_scc.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/test - test_scc.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:5050100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph/experimental/test/test_scc.c: tests for Strongly Connected Components
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // todo: write a simple scc method, as LG_check_scc, and compare its results
+      19             : // with LAGraph_scc
+      20             : 
+      21             : #include <stdio.h>
+      22             : #include <acutest.h>
+      23             : 
+      24             : #include <LAGraphX.h>
+      25             : #include <LAGraph_test.h>
+      26             : 
+      27             : char msg [LAGRAPH_MSG_LEN] ;
+      28             : LAGraph_Graph G = NULL ;
+      29             : GrB_Matrix A = NULL ;
+      30             : #define LEN 512
+      31             : char filename [LEN+1] ;
+      32             : 
+      33             : typedef struct
+      34             : {
+      35             :     const char *name ;
+      36             : }
+      37             : matrix_info ;
+      38             : 
+      39             : int scc_cover [7] = { 0, 0, 2, 0, 4, 2, 0 } ;
+      40             : 
+      41             : const matrix_info files [ ] =
+      42             : {
+      43             :     { "A2.mtx" },
+      44             :     { "A.mtx" },
+      45             :     { "bcsstk13.mtx" },
+      46             :     { "cover.mtx" },
+      47             :     { "cover_structure.mtx" },
+      48             :     { "cryg2500.mtx" },
+      49             :     { "full.mtx" },
+      50             :     { "full_noheader.mtx" },
+      51             :     { "full_symmetric.mtx" },
+      52             :     { "jagmesh7.mtx" },
+      53             :     { "karate.mtx" },
+      54             :     { "ldbc-cdlp-directed-example.mtx" },
+      55             :     { "ldbc-cdlp-undirected-example.mtx" },
+      56             :     { "ldbc-directed-example-bool.mtx" },
+      57             :     { "ldbc-directed-example.mtx" },
+      58             :     { "ldbc-directed-example-unweighted.mtx" },
+      59             :     { "ldbc-undirected-example-bool.mtx" },
+      60             :     { "ldbc-undirected-example.mtx" },
+      61             :     { "ldbc-undirected-example-unweighted.mtx" },
+      62             :     { "ldbc-wcc-example.mtx" },
+      63             :     { "LFAT5.mtx" },
+      64             :     { "LFAT5_two.mtx" },
+      65             :     { "matrix_bool.mtx" },
+      66             :     { "matrix_fp32.mtx" },
+      67             :     { "matrix_fp32_structure.mtx" },
+      68             :     { "matrix_fp64.mtx" },
+      69             :     { "matrix_int16.mtx" },
+      70             :     { "matrix_int32.mtx" },
+      71             :     { "matrix_int64.mtx" },
+      72             :     { "matrix_int8.mtx" },
+      73             :     { "matrix_uint16.mtx" },
+      74             :     { "matrix_uint32.mtx" },
+      75             :     { "matrix_uint64.mtx" },
+      76             :     { "matrix_uint8.mtx" },
+      77             :     { "msf1.mtx" },
+      78             :     { "msf2.mtx" },
+      79             :     { "msf3.mtx" },
+      80             :     { "olm1000.mtx" },
+      81             :     { "pushpull.mtx" },
+      82             :     { "sample2.mtx" },
+      83             :     { "sample.mtx" },
+      84             :     { "structure.mtx" },
+      85             :     { "test_BF.mtx" },
+      86             :     { "test_FW_1000.mtx" },
+      87             :     { "test_FW_2003.mtx" },
+      88             :     { "test_FW_2500.mtx" },
+      89             :     { "tree-example.mtx" },
+      90             :     { "west0067_jumbled.mtx" },
+      91             :     { "west0067.mtx" },
+      92             :     { "west0067_noheader.mtx" },
+      93             :     { "zenios.mtx" },
+      94             :     { "" },
+      95             : } ;
+      96             : 
+      97             : //****************************************************************************
+      98           1 : void test_scc (void)
+      99             : {
+     100           1 :     LAGraph_Init (msg) ;
+     101             :     #if LAGRAPH_SUITESPARSE
+     102             : 
+     103           1 :     for (int k = 0 ; ; k++)
+     104          51 :     {
+     105             : 
+     106             :         // load the matrix as A
+     107          52 :         const char *aname = files [k].name ;
+     108          52 :         if (strlen (aname) == 0) break;
+     109          51 :         printf ("\n================================== %s:\n", aname) ;
+     110          51 :         TEST_CASE (aname) ;
+     111          51 :         snprintf (filename, LEN, LG_DATA_DIR "%s", aname) ;
+     112          51 :         FILE *f = fopen (filename, "r") ;
+     113          51 :         TEST_CHECK (f != NULL) ;
+     114          51 :         OK (LAGraph_MMRead (&A, f, msg)) ;
+     115             : 
+     116             :         // construct a directed graph G with adjacency matrix A
+     117          51 :         OK (LAGraph_New (&G, &A, LAGraph_ADJACENCY_DIRECTED, msg)) ;
+     118          51 :         TEST_CHECK (A == NULL) ;
+     119             : 
+     120          51 :         GrB_Vector c = NULL ;
+     121             : 
+     122             :         // find the strongly connected components with LAGraph_scc
+     123          51 :         OK (LAGraph_scc (&c, G->A, msg)) ;
+     124             : 
+     125             :         GrB_Index n ;
+     126          51 :         OK (GrB_Vector_size (&n, c)) ;
+     127          51 :         LAGraph_PrintLevel pr = (n <= 100) ? LAGraph_COMPLETE : LAGraph_SHORT ;
+     128             : 
+     129             :         // check result c for cover
+     130          51 :         if (strcmp (aname, "cover.mtx") == 0)
+     131             :         {
+     132           1 :             GrB_Vector cgood = NULL ;
+     133           1 :             OK (GrB_Vector_new (&cgood, GrB_UINT64, n)) ;
+     134           8 :             for (int k = 0 ; k < n ; k++)
+     135             :             {
+     136           7 :                 OK (GrB_Vector_setElement (cgood, scc_cover [k], k)) ;
+     137             :             }
+     138           1 :             OK (GrB_wait (cgood, GrB_MATERIALIZE)) ;
+     139           1 :             printf ("\nscc (known result):\n") ;
+     140           1 :             OK (LAGraph_Vector_Print (cgood, pr, stdout, msg)) ;
+     141           1 :             bool ok = false ;
+     142           1 :             OK (LAGraph_Vector_IsEqual (&ok, c, cgood, msg)) ;
+     143           1 :             TEST_CHECK (ok) ;
+     144           1 :             OK (GrB_free (&cgood)) ;
+     145             :         }
+     146             : 
+     147          51 :         printf ("\nscc:\n") ;
+     148          51 :         OK (LAGraph_Vector_Print (c, pr, stdout, msg)) ;
+     149          51 :         OK (GrB_free (&c)) ;
+     150          51 :         OK (LAGraph_Delete (&G, msg)) ;
+     151             :     }
+     152             : 
+     153             :     #else
+     154             :     printf ("test skipped\n") ;
+     155             :     #endif
+     156           1 :     LAGraph_Finalize (msg) ;
+     157           1 : }
+     158             : 
+     159             : //------------------------------------------------------------------------------
+     160             : // test_errors
+     161             : //------------------------------------------------------------------------------
+     162             : 
+     163           1 : void test_errors (void)
+     164             : {
+     165           1 :     LAGraph_Init (msg) ;
+     166             :     #if LAGRAPH_SUITESPARSE
+     167             : 
+     168           1 :     GrB_Vector c = NULL ;
+     169           1 :     GrB_Matrix A = NULL ;
+     170             : 
+     171             :     // c and A are NULL
+     172           1 :     int result = LAGraph_scc (NULL, A, msg) ;
+     173           1 :     printf ("\nresult: %d\n", result) ;
+     174           1 :     TEST_CHECK (result == GrB_NULL_POINTER) ;
+     175             : 
+     176             :     // A is rectangular
+     177           1 :     OK (GrB_Matrix_new (&A, GrB_BOOL, 3, 4)) ;
+     178           1 :     result = LAGraph_scc (&c, A, msg) ;
+     179           1 :     TEST_CHECK (result == GrB_DIMENSION_MISMATCH) ;
+     180             : 
+     181           1 :     OK (GrB_free (&c)) ;
+     182           1 :     OK (GrB_free (&A)) ;
+     183             :     #else
+     184             :     printf ("test skipped\n") ;
+     185             :     #endif
+     186           1 :     LAGraph_Finalize (msg) ;
+     187           1 : }
+     188             : 
+     189             : //****************************************************************************
+     190             : 
+     191             : TEST_LIST = {
+     192             :     {"scc", test_scc},
+     193             :     {"scc_errors", test_errors},
+     194             :     {NULL, NULL}
+     195             : };
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/utility/LAGraph_Random.c.func-sort-c.html b/experimental/utility/LAGraph_Random.c.func-sort-c.html new file mode 100644 index 0000000000..070c248292 --- /dev/null +++ b/experimental/utility/LAGraph_Random.c.func-sort-c.html @@ -0,0 +1,92 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/utility/LAGraph_Random.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/utility - LAGraph_Random.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3737100.0 %
Date:2024-08-29 20:08:04Functions:55100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_Random_Finalize5
LAGraph_Random_Init5
LAGraph_Random_Seed833
LAGraph_Random_Next1108
LG_rand_next_f285699
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/utility/LAGraph_Random.c.func.html b/experimental/utility/LAGraph_Random.c.func.html new file mode 100644 index 0000000000..2d63a0a9c6 --- /dev/null +++ b/experimental/utility/LAGraph_Random.c.func.html @@ -0,0 +1,92 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/utility/LAGraph_Random.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/utility - LAGraph_Random.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3737100.0 %
Date:2024-08-29 20:08:04Functions:55100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_Random_Finalize5
LAGraph_Random_Init5
LAGraph_Random_Next1108
LAGraph_Random_Seed833
LG_rand_next_f285699
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/utility/LAGraph_Random.c.gcov.html b/experimental/utility/LAGraph_Random.c.gcov.html new file mode 100644 index 0000000000..8f77079200 --- /dev/null +++ b/experimental/utility/LAGraph_Random.c.gcov.html @@ -0,0 +1,252 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/utility/LAGraph_Random.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/utility - LAGraph_Random.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3737100.0 %
Date:2024-08-29 20:08:04Functions:55100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_Random: generate a random vector (of any sparsity structure)
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // A very simple thread-safe parallel pseudo-random nuumber generator.
+      19             : 
+      20             : // FUTURE: add LAGraph_Random_Init to LAGraph_Init,
+      21             : // and added LAGraph_Random_Finalize to LAGraph_Finalize.
+      22             : 
+      23             : #include "LG_internal.h"
+      24             : #include "LAGraphX.h"
+      25             : 
+      26             : //------------------------------------------------------------------------------
+      27             : // LG_RAND macros
+      28             : //------------------------------------------------------------------------------
+      29             : 
+      30             : // Generate the next seed
+      31             : #define LG_RAND_NEXT(seed) ((seed) * 1103515245 + 12345)
+      32             : 
+      33             : // extract a random 15-bit value from a seed (no longer used)
+      34             : // #define LG_RAND_15_MAX 32767
+      35             : // #define LG_RAND_15(seed) (((seed)/65536) % (LG_RAND_15_MAX + 1))
+      36             : 
+      37             : //------------------------------------------------------------------------------
+      38             : // global operator
+      39             : //------------------------------------------------------------------------------
+      40             : 
+      41             : // This operator can be shared by all threads in a user application, and thus
+      42             : // is safely declared as a global object.
+      43             : 
+      44             : GrB_UnaryOp LG_rand_next_op = NULL ;
+      45             : 
+      46             : //------------------------------------------------------------------------------
+      47             : // LG_rand_next_f:  unary operator to construct the next seed
+      48             : //------------------------------------------------------------------------------
+      49             : 
+      50             : // z = f(x), where x is the old seed and z is the new seed.
+      51             : 
+      52      285699 : void LG_rand_next_f (void *z, const void *x)
+      53             : {
+      54      285699 :     uint64_t seed = (*((uint64_t *) x)) ;
+      55      285699 :     seed = LG_RAND_NEXT (seed) ;
+      56      285699 :     seed = LG_RAND_NEXT (seed) ;
+      57      285699 :     seed = LG_RAND_NEXT (seed) ;
+      58      285699 :     seed = LG_RAND_NEXT (seed) ;
+      59      285699 :     seed = LG_RAND_NEXT (seed) ;
+      60      285699 :     (*((uint64_t *) z)) = seed ;
+      61      285699 : }
+      62             : 
+      63             : //------------------------------------------------------------------------------
+      64             : // LAGraph_Random_Init:  create the random seed operator
+      65             : //------------------------------------------------------------------------------
+      66             : 
+      67             : #undef  LG_FREE_WORK
+      68             : #define LG_FREE_WORK                                        \
+      69             : {                                                           \
+      70             :     GrB_UnaryOp_free (&LG_rand_next_op) ;                   \
+      71             : }
+      72             : 
+      73           5 : int LAGraph_Random_Init (char *msg)
+      74             : {
+      75           5 :     LG_CLEAR_MSG ;
+      76           5 :     LG_rand_next_op = NULL ;
+      77           5 :     GRB_TRY (GrB_UnaryOp_new (&LG_rand_next_op, LG_rand_next_f,
+      78             :         GrB_UINT64, GrB_UINT64)) ;
+      79           5 :     return (GrB_SUCCESS) ;
+      80             : }
+      81             : 
+      82             : //------------------------------------------------------------------------------
+      83             : // LAGraph_Random_Finalize:  free the random seed operator
+      84             : //------------------------------------------------------------------------------
+      85             : 
+      86           5 : int LAGraph_Random_Finalize (char *msg)
+      87             : {
+      88           5 :     LG_CLEAR_MSG ;
+      89           5 :     LG_FREE_WORK ;
+      90           5 :     return (GrB_SUCCESS) ;
+      91             : }
+      92             : 
+      93             : //------------------------------------------------------------------------------
+      94             : // LAGraph_Random_Seed:  create a vector of random seeds
+      95             : //------------------------------------------------------------------------------
+      96             : 
+      97             : // Initializes a vector with random seed values.  The Seed vector must be
+      98             : // allocated on input, and should be of type GrB_UINT64.  Its sparsity
+      99             : // structure is unchanged.
+     100             : 
+     101             : #undef  LG_FREE_WORK
+     102             : #define LG_FREE_WORK GrB_free (&T) ;
+     103             : 
+     104             : #if defined ( COVERAGE )
+     105             : // for testing only
+     106             : bool random_hack = false ;
+     107             : #endif
+     108             : 
+     109         833 : int LAGraph_Random_Seed     // construct a random seed vector
+     110             : (
+     111             :     // input/output
+     112             :     GrB_Vector Seed,    // GrB_UINT64 vector of random number seeds
+     113             :     // input
+     114             :     uint64_t seed,      // scalar input seed
+     115             :     char *msg
+     116             : )
+     117             : {
+     118             :     // check inputs
+     119         833 :     LG_CLEAR_MSG ;
+     120         833 :     GrB_Vector T = NULL ;
+     121         833 :     LG_ASSERT (Seed != NULL, GrB_NULL_POINTER) ;
+     122             : 
+     123             :     // T = 1:n but only for entries present in the Seed vector.  This
+     124             :     // requires a typecast from int64 to uint64.
+     125             :     GrB_Index n ;
+     126         833 :     GRB_TRY (GrB_Vector_size (&n, Seed)) ;
+     127         833 :     GRB_TRY (GrB_Vector_new (&T, GrB_UINT64, n)) ;
+     128         833 :     GRB_TRY (GrB_Vector_apply_IndexOp_INT64 (T, NULL, NULL,
+     129             :         GrB_ROWINDEX_INT64, Seed, 1, NULL)) ;
+     130             : 
+     131             :     // Seed = T * INT32_MAX
+     132         833 :     GRB_TRY (GrB_apply (Seed, NULL, NULL, GrB_TIMES_UINT64, T,
+     133             :         (uint64_t) INT32_MAX, NULL)) ;
+     134             : 
+     135             :     // Seed = Seed + seed
+     136         833 :     GRB_TRY (GrB_apply (Seed, NULL, NULL, GrB_PLUS_UINT64, Seed, seed, NULL)) ;
+     137             : 
+     138             :     // Seed = next (Seed)
+     139         833 :     GRB_TRY (GrB_Vector_apply (Seed, NULL, NULL, LG_rand_next_op, Seed, NULL)) ;
+     140             : 
+     141             :     #if defined ( COVERAGE )
+     142         833 :     if (random_hack)
+     143             :     {
+     144             :         // Set all Seed values to 1, to break the random seed vector.
+     145             :         // This is just for testing, to test algorithms that need to handle
+     146             :         // extreme cases when the random number generator is non-random.
+     147         432 :         GRB_TRY (GrB_Vector_apply_BinaryOp2nd_UINT64 (Seed, NULL, NULL,
+     148             :             GrB_ONEB_UINT64, Seed, 0, NULL)) ;
+     149             :     }
+     150             :     #endif
+     151             : 
+     152         833 :     LG_FREE_WORK ;
+     153         833 :     return (GrB_SUCCESS) ;
+     154             : }
+     155             : 
+     156             : //------------------------------------------------------------------------------
+     157             : // LAGraph_Random_Next: return next vector of random seeds
+     158             : //------------------------------------------------------------------------------
+     159             : 
+     160             : #undef  LG_FREE_WORK
+     161             : #define LG_FREE_WORK ;
+     162             : 
+     163        1108 : int LAGraph_Random_Next     // advance to next random vector
+     164             : (
+     165             :     // input/output
+     166             :     GrB_Vector Seed,        // the sparsity pattern of Seed is preserved
+     167             :     char *msg
+     168             : )
+     169             : {
+     170             :     // check inputs
+     171        1108 :     LG_CLEAR_MSG ;
+     172        1108 :     LG_ASSERT (Seed != NULL, GrB_NULL_POINTER) ;
+     173             :     // Seed = next (Seed)
+     174        1108 :     GRB_TRY (GrB_Vector_apply (Seed, NULL, NULL, LG_rand_next_op, Seed, NULL)) ;
+     175        1108 :     return (GrB_SUCCESS) ;
+     176             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/utility/LAGraph_Random_Matrix.c.func-sort-c.html b/experimental/utility/LAGraph_Random_Matrix.c.func-sort-c.html new file mode 100644 index 0000000000..63afcfe1b4 --- /dev/null +++ b/experimental/utility/LAGraph_Random_Matrix.c.func-sort-c.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/utility/LAGraph_Random_Matrix.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/utility - LAGraph_Random_Matrix.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:8484100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_Random_Matrix57
mod_function660
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/utility/LAGraph_Random_Matrix.c.func.html b/experimental/utility/LAGraph_Random_Matrix.c.func.html new file mode 100644 index 0000000000..f9afc8c7e9 --- /dev/null +++ b/experimental/utility/LAGraph_Random_Matrix.c.func.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/utility/LAGraph_Random_Matrix.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/utility - LAGraph_Random_Matrix.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:8484100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_Random_Matrix57
mod_function660
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/utility/LAGraph_Random_Matrix.c.gcov.html b/experimental/utility/LAGraph_Random_Matrix.c.gcov.html new file mode 100644 index 0000000000..e167334945 --- /dev/null +++ b/experimental/utility/LAGraph_Random_Matrix.c.gcov.html @@ -0,0 +1,515 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/utility/LAGraph_Random_Matrix.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/utility - LAGraph_Random_Matrix.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:8484100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_Random_Matrix: generate a random matrix
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // Constructs a sparse roughly uniformly distributed random matrix with roughly
+      19             : // density*nrows*ncols entries.  If density == INFINITY then the matrix is
+      20             : // generated with all entries present.
+      21             : 
+      22             : // If the type is GrB_FP32 or GrB_FP64, the values of A are returned in the
+      23             : // range [0,1].  If any duplicate entries are generated, the largest one is
+      24             : // take, so the distribution can be skewed towards 1 if the density is large.
+      25             : // This could be fixed by using the GxB_IGNORE_DUP operator, but this would
+      26             : // require SuiteSparse:GraphBLAS.
+      27             : 
+      28             : #define LG_FREE_WORK                            \
+      29             : {                                               \
+      30             :     LAGraph_Free ((void **) &I, NULL) ;         \
+      31             :     LAGraph_Free ((void **) &J, NULL) ;         \
+      32             :     LAGraph_Free ((void **) &ignore, NULL) ;    \
+      33             :     LAGraph_Free (&X, NULL) ;                   \
+      34             :     GrB_free (&Mod) ;                           \
+      35             :     GrB_free (&Rows) ;                          \
+      36             :     GrB_free (&Cols) ;                          \
+      37             :     GrB_free (&Values) ;                        \
+      38             :     GrB_free (&Seed) ;                          \
+      39             :     GrB_free (&T) ;                             \
+      40             : }
+      41             : 
+      42             : #define LG_FREE_ALL                             \
+      43             : {                                               \
+      44             :     LG_FREE_WORK ;                              \
+      45             :     GrB_free (A) ;                              \
+      46             : }
+      47             : 
+      48             : #include "LG_internal.h"
+      49             : #include "LAGraphX.h"
+      50             : 
+      51             : // uncomment these to test vanilla case for just this file:
+      52             : // #undef LAGRAPH_SUITESPARSE
+      53             : // #define LAGRAPH_SUITESPARSE 0
+      54             : 
+      55             : //------------------------------------------------------------------------------
+      56             : // mod function for uint64: z = x % y
+      57             : //------------------------------------------------------------------------------
+      58             : 
+      59         660 : void mod_function (void *z, const void *x, const void *y)
+      60             : {
+      61         660 :     uint64_t a = (*((uint64_t *) x)) ;
+      62         660 :     uint64_t b = (*((uint64_t *) y)) ;
+      63         660 :     (*((uint64_t *) z)) = a % b ;
+      64         660 : }
+      65             : 
+      66             : //------------------------------------------------------------------------------
+      67             : // LAGraph_Random_Matrix
+      68             : //------------------------------------------------------------------------------
+      69             : 
+      70          57 : GrB_Info LAGraph_Random_Matrix    // random matrix of any built-in type
+      71             : (
+      72             :     // output
+      73             :     GrB_Matrix *A,      // A is constructed on output
+      74             :     // input
+      75             :     GrB_Type type,      // type of matrix to construct
+      76             :     GrB_Index nrows,    // # of rows of A
+      77             :     GrB_Index ncols,    // # of columns of A
+      78             :     double density,     // density: build a sparse matrix with
+      79             :                         // density*nrows*cols values if not INFINITY;
+      80             :                         // build a dense matrix if INFINITY.
+      81             :     uint64_t seed,      // random number seed
+      82             :     char *msg
+      83             : )
+      84             : {
+      85             : 
+      86             :     //--------------------------------------------------------------------------
+      87             :     // check inputs
+      88             :     //--------------------------------------------------------------------------
+      89             : 
+      90          57 :     LG_CLEAR_MSG ;
+      91          57 :     GrB_BinaryOp Mod = NULL ;
+      92          57 :     GrB_Vector Rows = NULL, Cols = NULL, Values = NULL, Seed = NULL ;
+      93          57 :     GrB_Matrix T = NULL ;
+      94          57 :     GrB_Index *I = NULL, *J = NULL, *ignore = NULL ;
+      95          57 :     GrB_Index I_size = 0, J_size = 0, X_size = 0 ;
+      96          57 :     void *X = NULL ;
+      97          57 :     LG_ASSERT (A != NULL && type != NULL, GrB_NULL_POINTER) ;
+      98          57 :     LG_ASSERT_MSG (density >= 0, GrB_INVALID_VALUE, "invalid density") ;
+      99             : 
+     100          57 :     LG_ASSERT_MSG (type == GrB_BOOL
+     101             :         || type == GrB_INT8   || type == GrB_INT16 || type == GrB_INT32
+     102             :         || type == GrB_INT64  || type == GrB_UINT8 || type == GrB_UINT16
+     103             :         || type == GrB_UINT32 || type == GrB_UINT64
+     104             :         || type == GrB_FP32   || type == GrB_FP64,
+     105             :         GrB_NOT_IMPLEMENTED, "unsupported type") ;
+     106             : 
+     107          56 :     GRB_TRY (GrB_Matrix_new (A, type, nrows, ncols)) ;
+     108          56 :     if (nrows == 0 || ncols == 0)
+     109             :     {
+     110             :         // nothing to do: return A as the requested empty matrix
+     111           1 :         return (GrB_SUCCESS) ;
+     112             :     }
+     113             : 
+     114             :     //--------------------------------------------------------------------------
+     115             :     // create the Mod operator
+     116             :     //--------------------------------------------------------------------------
+     117             : 
+     118          55 :     GRB_TRY (GrB_BinaryOp_new (&Mod, mod_function,
+     119             :         GrB_UINT64, GrB_UINT64, GrB_UINT64)) ;
+     120             : 
+     121             :     //--------------------------------------------------------------------------
+     122             :     // determine the number of entries to generate
+     123             :     //--------------------------------------------------------------------------
+     124             : 
+     125          55 :     bool A_is_full = isinf (density) ;
+     126             :     GrB_Index nvals ;
+     127          55 :     if (A_is_full)
+     128             :     {
+     129             :         // determine number of tuples for building a random dense matrix
+     130          11 :         double nx = (double) nrows * (double) ncols ;
+     131          11 :         LG_ASSERT_MSG (nx < (double) GrB_INDEX_MAX, GrB_OUT_OF_MEMORY,
+     132             :             "Problem too large") ;
+     133          11 :         nvals = nrows * ncols ;
+     134             :     }
+     135             :     else
+     136             :     {
+     137             :         // determine number of tuples for building a random sparse matrix
+     138          44 :         double nx = density * (double) nrows * (double) ncols ;
+     139          44 :         nx = round (nx) ;
+     140          44 :         nx = fmax (nx, (double) 0) ;
+     141          44 :         nx = fmin (nx, (double) GrB_INDEX_MAX) ;
+     142          44 :         nvals = (GrB_Index) nx ;
+     143             :     }
+     144             : 
+     145             :     //--------------------------------------------------------------------------
+     146             :     // allocate workspace
+     147             :     //--------------------------------------------------------------------------
+     148             : 
+     149             :     #if !LAGRAPH_SUITESPARSE
+     150             :     {
+     151             :         LG_TRY (LAGraph_Malloc ((void **) &ignore, nvals, sizeof (GrB_Index),
+     152             :             msg)) ;
+     153             :         LG_TRY (LAGraph_Malloc ((void **) &I, nvals, sizeof (GrB_Index), msg)) ;
+     154             :         LG_TRY (LAGraph_Malloc ((void **) &J, nvals, sizeof (GrB_Index), msg)) ;
+     155             :     }
+     156             :     #endif
+     157             : 
+     158             :     //--------------------------------------------------------------------------
+     159             :     // construct the random Seed vector
+     160             :     //--------------------------------------------------------------------------
+     161             : 
+     162          55 :     GRB_TRY (GrB_Vector_new (&Seed, GrB_UINT64, nvals)) ;
+     163          55 :     GRB_TRY (GrB_assign (Seed, NULL, NULL, 0, GrB_ALL, nvals, NULL)) ;
+     164          55 :     LG_TRY (LAGraph_Random_Seed (Seed, seed, msg)) ;
+     165             : 
+     166             :     //--------------------------------------------------------------------------
+     167             :     // construct the random indices if A is sparse, or all indices if full
+     168             :     //--------------------------------------------------------------------------
+     169             : 
+     170          55 :     if (!A_is_full)
+     171             :     {
+     172             : 
+     173             :         //----------------------------------------------------------------------
+     174             :         // construct random indices for a sparse matrix
+     175             :         //----------------------------------------------------------------------
+     176             : 
+     177             :         // Rows = mod (Seed, nrows) ;
+     178          44 :         GRB_TRY (GrB_Vector_new (&Rows, GrB_UINT64, nvals)) ;
+     179          44 :         GRB_TRY (GrB_apply (Rows, NULL, NULL, Mod, Seed, nrows, NULL)) ;
+     180             : 
+     181             :         // Seed = next (Seed)
+     182          44 :         LG_TRY (LAGraph_Random_Next (Seed, msg)) ;
+     183             : 
+     184             :         // Cols = mod (Seed, ncols) ;
+     185          44 :         GRB_TRY (GrB_Vector_new (&Cols, GrB_UINT64, nvals)) ;
+     186          44 :         GRB_TRY (GrB_apply (Cols, NULL, NULL, Mod, Seed, ncols, NULL)) ;
+     187             : 
+     188             :         // Seed = next (Seed)
+     189          44 :         LG_TRY (LAGraph_Random_Next (Seed, msg)) ;
+     190             : 
+     191             :         //----------------------------------------------------------------------
+     192             :         // extract the indices
+     193             :         //----------------------------------------------------------------------
+     194             : 
+     195             :         #if LAGRAPH_SUITESPARSE
+     196             :         {
+     197             :             // this takes O(1) time and space
+     198          44 :             GRB_TRY (GxB_Vector_unpack_Full (Rows, (void **) &I, &I_size,
+     199             :                 NULL, NULL)) ;
+     200          44 :             GRB_TRY (GxB_Vector_unpack_Full (Cols, (void **) &J, &J_size,
+     201             :                 NULL, NULL)) ;
+     202             :         }
+     203             :         #else
+     204             :         {
+     205             :             // this takes O(nvals) time and space
+     206             :             GRB_TRY (GrB_Vector_extractTuples_UINT64 (ignore, I, &nvals,
+     207             :                 Rows)) ;
+     208             :             GRB_TRY (GrB_Vector_extractTuples_UINT64 (ignore, J, &nvals,
+     209             :                 Cols)) ;
+     210             :         }
+     211             :         #endif
+     212             : 
+     213          44 :         GrB_free (&Rows) ;
+     214          44 :         GrB_free (&Cols) ;
+     215             : 
+     216             :     }
+     217             :     else
+     218             :     {
+     219             : 
+     220             :         //----------------------------------------------------------------------
+     221             :         // construct indices for a full matrix
+     222             :         //----------------------------------------------------------------------
+     223             : 
+     224             :         #if !LAGRAPH_SUITESPARSE
+     225             :         {
+     226             :             // T = true (nrows, ncols) ;
+     227             :             GRB_TRY (GrB_Matrix_new (&T, GrB_BOOL, nrows, ncols)) ;
+     228             :             GRB_TRY (GrB_assign (T, NULL, NULL, true,
+     229             :                 GrB_ALL, nrows, GrB_ALL, ncols, NULL)) ;
+     230             :             // extract the row and column indices from T
+     231             :             GRB_TRY (GrB_Matrix_extractTuples (I, J, (bool *) ignore, &nvals,
+     232             :                 T)) ;
+     233             :             GrB_free (&T) ;
+     234             :         }
+     235             :         #endif
+     236             :     }
+     237             : 
+     238             :     //-------------------------------------------------------------------------
+     239             :     // construct the random values
+     240             :     //-------------------------------------------------------------------------
+     241             : 
+     242          55 :     if (type == GrB_BOOL)
+     243             :     {
+     244             :         // Values = (Seed < UINT64_MAX / 2)
+     245           5 :         GRB_TRY (GrB_Vector_new (&Values, GrB_BOOL, nvals)) ;
+     246           5 :         GRB_TRY (GrB_apply (Values, NULL, NULL,
+     247             :             GrB_LT_UINT64, Seed, UINT64_MAX / 2, NULL)) ;
+     248             :     }
+     249          50 :     else if (type == GrB_UINT64)
+     250             :     {
+     251             :         // no need to allocate the Values vector; just use the Seed itself
+     252           5 :         Values = Seed ;
+     253           5 :         Seed = NULL ;
+     254             :     }
+     255             :     else
+     256             :     {
+     257             :         // Values = (type) Seed
+     258          45 :         GRB_TRY (GrB_Vector_new (&Values, type, nvals)) ;
+     259          45 :         GRB_TRY (GrB_assign (Values, NULL, NULL, Seed, GrB_ALL, nvals,
+     260             :             NULL)) ;
+     261             :     }
+     262          55 :     GrB_free (&Seed) ;
+     263             : 
+     264             :     // scale the values to the range [0,1], if floating-point
+     265          55 :     if (type == GrB_FP32)
+     266             :     {
+     267             :         // Values = Values / (float) UINT64_MAX
+     268           5 :         GRB_TRY (GrB_apply (Values, NULL, NULL, GrB_DIV_FP32,
+     269             :             Values, (float) UINT64_MAX, NULL)) ;
+     270             :     }
+     271          50 :     else if (type == GrB_FP64)
+     272             :     {
+     273             :         // Values = Values / (double) UINT64_MAX
+     274           5 :         GRB_TRY (GrB_apply (Values, NULL, NULL, GrB_DIV_FP64,
+     275             :             Values, (double) UINT64_MAX, NULL)) ;
+     276             :     }
+     277             : 
+     278             :     //--------------------------------------------------------------------------
+     279             :     // extract the values
+     280             :     //--------------------------------------------------------------------------
+     281             : 
+     282             :     #if LAGRAPH_SUITESPARSE
+     283             :     {
+     284             :         // this takes O(1) time and space and works for any data type
+     285          55 :         GRB_TRY (GxB_Vector_unpack_Full (Values, &X, &X_size, NULL, NULL)) ;
+     286             :     }
+     287             :     #else
+     288             :     {
+     289             :         // this takes O(nvals) time and space
+     290             :         if (type == GrB_BOOL)
+     291             :         {
+     292             :             LG_TRY (LAGraph_Malloc ((void **) &X, nvals, sizeof (bool), msg)) ;
+     293             :             GRB_TRY (GrB_Vector_extractTuples_BOOL (ignore, X, &nvals,
+     294             :                 Values)) ;
+     295             :         }
+     296             :         else if (type == GrB_INT8)
+     297             :         {
+     298             :             LG_TRY (LAGraph_Malloc ((void **) &X, nvals, sizeof (int8_t),
+     299             :                 msg)) ;
+     300             :             GRB_TRY (GrB_Vector_extractTuples_INT8 (ignore, X, &nvals,
+     301             :                 Values)) ;
+     302             :         }
+     303             :         else if (type == GrB_INT16)
+     304             :         {
+     305             :             LG_TRY (LAGraph_Malloc ((void **) &X, nvals, sizeof (int16_t),
+     306             :                 msg)) ;
+     307             :             GRB_TRY (GrB_Vector_extractTuples_INT16 (ignore, X, &nvals,
+     308             :                 Values)) ;
+     309             :         }
+     310             :         else if (type == GrB_INT32)
+     311             :         {
+     312             :             LG_TRY (LAGraph_Malloc ((void **) &X, nvals, sizeof (int32_t),
+     313             :                 msg)) ;
+     314             :             GRB_TRY (GrB_Vector_extractTuples_INT32 (ignore, X, &nvals,
+     315             :                 Values)) ;
+     316             :         }
+     317             :         else if (type == GrB_INT64)
+     318             :         {
+     319             :             LG_TRY (LAGraph_Malloc ((void **) &X, nvals, sizeof (int64_t),
+     320             :                 msg)) ;
+     321             :             GRB_TRY (GrB_Vector_extractTuples_INT64 (ignore, X, &nvals,
+     322             :                 Values)) ;
+     323             :         }
+     324             :         else if (type == GrB_UINT8)
+     325             :         {
+     326             :             LG_TRY (LAGraph_Malloc ((void **) &X, nvals, sizeof (uint8_t),
+     327             :                 msg)) ;
+     328             :             GRB_TRY (GrB_Vector_extractTuples_UINT8 (ignore, X, &nvals,
+     329             :                 Values)) ;
+     330             :         }
+     331             :         else if (type == GrB_UINT16)
+     332             :         {
+     333             :             LG_TRY (LAGraph_Malloc ((void **) &X, nvals, sizeof (uint16_t),
+     334             :                 msg)) ;
+     335             :             GRB_TRY (GrB_Vector_extractTuples_UINT16 (ignore, X, &nvals,
+     336             :                 Values)) ;
+     337             :         }
+     338             :         else if (type == GrB_UINT32)
+     339             :         {
+     340             :             LG_TRY (LAGraph_Malloc ((void **) &X, nvals, sizeof (uint32_t),
+     341             :                 msg)) ;
+     342             :             GRB_TRY (GrB_Vector_extractTuples_UINT32 (ignore, X, &nvals,
+     343             :                 Values)) ;
+     344             :         }
+     345             :         else if (type == GrB_UINT64)
+     346             :         {
+     347             :             LG_TRY (LAGraph_Malloc ((void **) &X, nvals, sizeof (uint64_t),
+     348             :                 msg)) ;
+     349             :             GRB_TRY (GrB_Vector_extractTuples_UINT64 (ignore, X, &nvals,
+     350             :                 Values)) ;
+     351             :         }
+     352             :         else if (type == GrB_FP32)
+     353             :         {
+     354             :             LG_TRY (LAGraph_Malloc ((void **) &X, nvals, sizeof (float),
+     355             :                 msg)) ;
+     356             :             GRB_TRY (GrB_Vector_extractTuples_FP32 (ignore, X, &nvals,
+     357             :                 Values)) ;
+     358             :         }
+     359             :         else // if (type == GrB_FP64)
+     360             :         {
+     361             :             LG_TRY (LAGraph_Malloc ((void **) &X, nvals, sizeof (double),
+     362             :                 msg)) ;
+     363             :             GRB_TRY (GrB_Vector_extractTuples_FP64 (ignore, X, &nvals,
+     364             :                 Values)) ;
+     365             :         }
+     366             :         LAGraph_Free ((void **) &ignore, NULL) ;
+     367             :     }
+     368             :     #endif
+     369             : 
+     370          55 :     GrB_free (&Values) ;
+     371             : 
+     372             :     //--------------------------------------------------------------------------
+     373             :     // build the matrix
+     374             :     //--------------------------------------------------------------------------
+     375             : 
+     376             :     // Using GxB_IGNORE_DUP for the dup operator would be faster for
+     377             :     // SuiteSparse, but it would result in a different matrix as compared to
+     378             :     // the pure GrB case.
+     379             : 
+     380             :     #if LAGRAPH_SUITESPARSE
+     381          55 :     if (A_is_full)
+     382             :     {
+     383             :         // this takes O(1) time and space
+     384          11 :         GRB_TRY (GxB_Matrix_pack_FullR (*A, &X, X_size, false, NULL)) ;
+     385             :     }
+     386             :     else
+     387             :     #endif
+     388          44 :     if (type == GrB_BOOL)
+     389             :     {
+     390           4 :         GRB_TRY (GrB_Matrix_build_BOOL   (*A, I, J, X, nvals, GrB_LXOR)) ;
+     391             :     }
+     392          40 :     else if (type == GrB_INT8)
+     393             :     {
+     394           4 :         GRB_TRY (GrB_Matrix_build_INT8   (*A, I, J, X, nvals, GrB_PLUS_INT8)) ;
+     395             :     }
+     396          36 :     else if (type == GrB_INT16)
+     397             :     {
+     398           4 :         GRB_TRY (GrB_Matrix_build_INT16  (*A, I, J, X, nvals, GrB_PLUS_INT16)) ;
+     399             :     }
+     400          32 :     else if (type == GrB_INT32)
+     401             :     {
+     402           4 :         GRB_TRY (GrB_Matrix_build_INT32  (*A, I, J, X, nvals, GrB_PLUS_INT32)) ;
+     403             :     }
+     404          28 :     else if (type == GrB_INT64)
+     405             :     {
+     406           4 :         GRB_TRY (GrB_Matrix_build_INT64  (*A, I, J, X, nvals, GrB_PLUS_INT64)) ;
+     407             :     }
+     408          24 :     else if (type == GrB_UINT8)
+     409             :     {
+     410           4 :         GRB_TRY (GrB_Matrix_build_UINT8  (*A, I, J, X, nvals, GrB_PLUS_UINT8)) ;
+     411             :     }
+     412          20 :     else if (type == GrB_UINT16)
+     413             :     {
+     414           4 :         GRB_TRY (GrB_Matrix_build_UINT16 (*A, I, J, X, nvals, GrB_PLUS_UINT16));
+     415             :     }
+     416          16 :     else if (type == GrB_UINT32)
+     417             :     {
+     418           4 :         GRB_TRY (GrB_Matrix_build_UINT32 (*A, I, J, X, nvals, GrB_PLUS_UINT32));
+     419             :     }
+     420          12 :     else if (type == GrB_UINT64)
+     421             :     {
+     422           4 :         GRB_TRY (GrB_Matrix_build_UINT64 (*A, I, J, X, nvals, GrB_PLUS_UINT64));
+     423             :     }
+     424           8 :     else if (type == GrB_FP32)
+     425             :     {
+     426           4 :         GRB_TRY (GrB_Matrix_build_FP32   (*A, I, J, X, nvals, GrB_MAX_FP32)) ;
+     427             :     }
+     428             :     else // if (type == GrB_FP64)
+     429             :     {
+     430           4 :         GRB_TRY (GrB_Matrix_build_FP64   (*A, I, J, X, nvals, GrB_MAX_FP64)) ;
+     431             :     }
+     432             : 
+     433             :     //--------------------------------------------------------------------------
+     434             :     // free workspace and return result
+     435             :     //--------------------------------------------------------------------------
+     436             : 
+     437          55 :     LG_FREE_WORK ;
+     438          55 :     return (GrB_SUCCESS) ;
+     439             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/utility/LAGraph_SFreeContents.c.func-sort-c.html b/experimental/utility/LAGraph_SFreeContents.c.func-sort-c.html new file mode 100644 index 0000000000..79511b9508 --- /dev/null +++ b/experimental/utility/LAGraph_SFreeContents.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/utility/LAGraph_SFreeContents.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/utility - LAGraph_SFreeContents.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:88100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_SFreeContents8
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/utility/LAGraph_SFreeContents.c.func.html b/experimental/utility/LAGraph_SFreeContents.c.func.html new file mode 100644 index 0000000000..d004d1884d --- /dev/null +++ b/experimental/utility/LAGraph_SFreeContents.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/utility/LAGraph_SFreeContents.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/utility - LAGraph_SFreeContents.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:88100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_SFreeContents8
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/utility/LAGraph_SFreeContents.c.gcov.html b/experimental/utility/LAGraph_SFreeContents.c.gcov.html new file mode 100644 index 0000000000..81d6618b92 --- /dev/null +++ b/experimental/utility/LAGraph_SFreeContents.c.gcov.html @@ -0,0 +1,116 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/utility/LAGraph_SFreeContents.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/utility - LAGraph_SFreeContents.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:88100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_SFreeContents: free the Contents returned by LAGraph_SRead.
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include "LG_internal.h"
+      19             : #include "LAGraphX.h"
+      20             : 
+      21           8 : void LAGraph_SFreeContents  // free the Contents returned by LAGraph_SRead
+      22             : (
+      23             :     // input/output
+      24             :     LAGraph_Contents **Contents_handle,     // array of size ncontents
+      25             :     GrB_Index ncontents
+      26             : )
+      27             : {
+      28           8 :     if (Contents_handle != NULL)
+      29             :     {
+      30           8 :         LAGraph_Contents *Contents = (*Contents_handle) ;
+      31           8 :         if (Contents != NULL)
+      32             :         {
+      33         110 :             for (GrB_Index i = 0 ; i < ncontents ; i++)
+      34             :             {
+      35         105 :                 LAGraph_Free ((void **) &(Contents [i].blob), NULL) ;
+      36             :             }
+      37             :         }
+      38           8 :         LAGraph_Free ((void **) Contents_handle, NULL) ;
+      39             :     }
+      40           8 : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/utility/LAGraph_SFreeSet.c.func-sort-c.html b/experimental/utility/LAGraph_SFreeSet.c.func-sort-c.html new file mode 100644 index 0000000000..8ae0380c27 --- /dev/null +++ b/experimental/utility/LAGraph_SFreeSet.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/utility/LAGraph_SFreeSet.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/utility - LAGraph_SFreeSet.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:88100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_SFreeSet6
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/utility/LAGraph_SFreeSet.c.func.html b/experimental/utility/LAGraph_SFreeSet.c.func.html new file mode 100644 index 0000000000..5b318f3353 --- /dev/null +++ b/experimental/utility/LAGraph_SFreeSet.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/utility/LAGraph_SFreeSet.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/utility - LAGraph_SFreeSet.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:88100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_SFreeSet6
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/utility/LAGraph_SFreeSet.c.gcov.html b/experimental/utility/LAGraph_SFreeSet.c.gcov.html new file mode 100644 index 0000000000..93bc306e57 --- /dev/null +++ b/experimental/utility/LAGraph_SFreeSet.c.gcov.html @@ -0,0 +1,116 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/utility/LAGraph_SFreeSet.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/utility - LAGraph_SFreeSet.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:88100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_SFreeSet: free a set of matrices
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include "LG_internal.h"
+      19             : #include "LAGraphX.h"
+      20             : 
+      21           6 : void LAGraph_SFreeSet           // free a set of matrices
+      22             : (
+      23             :     // input/output
+      24             :     GrB_Matrix **Set_handle,    // array of GrB_Matrix of size nmatrices
+      25             :     GrB_Index nmatrices         // # of matrices in the set
+      26             : )
+      27             : {
+      28           6 :     if (Set_handle != NULL)
+      29             :     {
+      30           6 :         GrB_Matrix *Set = (*Set_handle) ;
+      31           6 :         if (Set != NULL)
+      32             :         {
+      33         106 :             for (GrB_Index i = 0 ; i < nmatrices ; i++)
+      34             :             {
+      35         103 :                 GrB_free (&(Set [i])) ;
+      36             :             }
+      37             :         }
+      38           6 :         LAGraph_Free ((void **) Set_handle, NULL) ;
+      39             :     }
+      40           6 : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/utility/LAGraph_SLoadSet.c.func-sort-c.html b/experimental/utility/LAGraph_SLoadSet.c.func-sort-c.html new file mode 100644 index 0000000000..af2f8864f3 --- /dev/null +++ b/experimental/utility/LAGraph_SLoadSet.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/utility/LAGraph_SLoadSet.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/utility - LAGraph_SLoadSet.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3333100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_SLoadSet5
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/utility/LAGraph_SLoadSet.c.func.html b/experimental/utility/LAGraph_SLoadSet.c.func.html new file mode 100644 index 0000000000..649dd92592 --- /dev/null +++ b/experimental/utility/LAGraph_SLoadSet.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/utility/LAGraph_SLoadSet.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/utility - LAGraph_SLoadSet.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3333100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_SLoadSet5
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/utility/LAGraph_SLoadSet.c.gcov.html b/experimental/utility/LAGraph_SLoadSet.c.gcov.html new file mode 100644 index 0000000000..1ba0581ee8 --- /dev/null +++ b/experimental/utility/LAGraph_SLoadSet.c.gcov.html @@ -0,0 +1,248 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/utility/LAGraph_SLoadSet.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/utility - LAGraph_SLoadSet.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3333100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_SLoadSet: load a set of matrices from a *.lagraph file
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // LAgraph_SLoadSet loads a set of GrB_Matrix objects from a *.lagraph file.
+      19             : // It returns a GrB_Matrix array of size nmatrices.  In the future, it will
+      20             : // also return a set of GrB_Vectors, and a an array of uncompressed ascii
+      21             : // texts.  The caller is responsible for freeing the output of this method,
+      22             : // via:
+      23             : 
+      24             : //      LAGraph_Free ((void **) &collection, NULL) ;
+      25             : //      LAGraph_SFreeSet (&Set, nmatrices) ;
+      26             : 
+      27             : // See also LAGraph_SRead, which just reads in the serialized objects and
+      28             : // does not convert them to their corresponding GrB_Matrix, GrB_Vector, or
+      29             : // uncompressed texts.
+      30             : 
+      31             : //------------------------------------------------------------------------------
+      32             : 
+      33             : #define LG_FREE_WORK                                                \
+      34             : {                                                                   \
+      35             :     if (f != NULL && f != stdin) fclose (f) ;                       \
+      36             :     f = NULL ;                                                      \
+      37             :     LAGraph_SFreeContents (&Contents, ncontents) ;                  \
+      38             : }
+      39             : 
+      40             : #define LG_FREE_ALL                                                 \
+      41             : {                                                                   \
+      42             :     LG_FREE_WORK ;                                                  \
+      43             :     LAGraph_SFreeSet (&Set, nmatrices) ;                            \
+      44             :     LAGraph_Free ((void **) &collection, NULL) ;                    \
+      45             : }
+      46             : 
+      47             : #include "LG_internal.h"
+      48             : #include "LAGraphX.h"
+      49             : 
+      50             : //------------------------------------------------------------------------------
+      51             : // LAGraph_SLoadSet
+      52             : //------------------------------------------------------------------------------
+      53             : 
+      54           5 : int LAGraph_SLoadSet            // load a set of matrices from a *.lagraph file
+      55             : (
+      56             :     // input:
+      57             :     char *filename,                 // name of file to read; NULL for stdin
+      58             :     // outputs:
+      59             :     GrB_Matrix **Set_handle,        // array of GrB_Matrix of size nmatrices
+      60             :     GrB_Index *nmatrices_handle,    // # of matrices loaded from *.lagraph file
+      61             : //  todo: handle vectors and text in LAGraph_SLoadSet
+      62             : //  GrB_Vector **Set_handle,        // array of GrB_Vector of size nvector
+      63             : //  GrB_Index **nvectors_handle,    // # of vectors loaded from *.lagraph file
+      64             : //  char **Text_handle,             // array of pointers to (char *) strings
+      65             : //  GrB_Index **ntext_handle,       // # of texts loaded from *.lagraph file
+      66             :     char **collection_handle,       // name of this collection of matrices
+      67             :     char *msg
+      68             : )
+      69             : {
+      70             : 
+      71             :     //--------------------------------------------------------------------------
+      72             :     // check inputs
+      73             :     //--------------------------------------------------------------------------
+      74             : 
+      75           5 :     LG_CLEAR_MSG ;
+      76           5 :     FILE *f = stdin ;
+      77           5 :     char *collection = NULL ;
+      78           5 :     GrB_Matrix *Set = NULL ;
+      79           5 :     LAGraph_Contents *Contents = NULL ;
+      80           5 :     GrB_Index ncontents = 0 ;
+      81           5 :     GrB_Index nmatrices = 0 ;
+      82             : //  GrB_Index nvectors = 0 ;
+      83             : //  GrB_Index ntexts = 0 ;
+      84             : 
+      85           5 :     LG_ASSERT (Set_handle != NULL && nmatrices_handle != NULL
+      86             :         && collection_handle != NULL, GrB_NULL_POINTER) ;
+      87             : 
+      88             :     //--------------------------------------------------------------------------
+      89             :     // read the file
+      90             :     //--------------------------------------------------------------------------
+      91             : 
+      92           4 :     if (filename != NULL)
+      93             :     {
+      94           4 :         f = fopen (filename, "rb") ;
+      95           4 :         LG_ASSERT_MSG (f != NULL,
+      96             :             LAGRAPH_IO_ERROR, "unable to open input file") ;
+      97             :     }
+      98           3 :     LG_TRY (LAGraph_SRead (f, &collection, &Contents, &ncontents, msg)) ;
+      99           2 :     if (filename != NULL)
+     100             :     {
+     101           2 :         fclose (f) ;
+     102             :     }
+     103           2 :     f = NULL ;
+     104             : 
+     105             :     //--------------------------------------------------------------------------
+     106             :     // count the matrices/vectors/texts in the Contents
+     107             :     //--------------------------------------------------------------------------
+     108             : 
+     109             :     // todo: for now, all Contents are matrices
+     110           2 :     nmatrices = ncontents ;
+     111             : 
+     112             : #if 0
+     113             :     for (GrB_Index i = 0 ; i < ncontents ; i++)
+     114             :     {
+     115             :         switch (Contents [i].kind)
+     116             :         {
+     117             :             case LAGraph_matrix_kind : nmatrices++ ; break ;
+     118             :             case LAGraph_vector_kind : nvectors++  ; break ;
+     119             :             case LAGraph_text_kind   : ntexts++    ; break ;
+     120             :             default : LG_ASSERT_MSG (false, GrB_INVALID_VALUE, "unknown kind") ;
+     121             :         }
+     122             :     }
+     123             :     if (nvectors > 0 || ntexts > 0)
+     124             :     {
+     125             :         // todo: handle vectors and texts
+     126             :         printf ("Warning: %lu vectors and %lu texts ignored\n",
+     127             :             nvectors, ntexts) ;
+     128             :     }
+     129             : #endif
+     130             : 
+     131             :     //--------------------------------------------------------------------------
+     132             :     // convert all the matrices (skip vectors and text content for now)
+     133             :     //--------------------------------------------------------------------------
+     134             : 
+     135           2 :     LG_TRY (LAGraph_Calloc ((void **) &Set, nmatrices, sizeof (GrB_Matrix),
+     136             :         msg)) ;
+     137             : 
+     138           2 :     GrB_Index kmatrices = 0 ;
+     139          54 :     for (GrB_Index i = 0 ; i < ncontents ; i++)
+     140             :     {
+     141             :         // convert Contents [i]
+     142          52 :         void *blob = Contents [i].blob ;
+     143          52 :         size_t blob_size = Contents [i].blob_size ;
+     144             : 
+     145          52 :         if (Contents [i].kind == LAGraph_matrix_kind)
+     146             :         {
+     147             :             // convert Contents [i].typename to a GrB_Type ctype.
+     148             :             // SuiteSparse:GraphBLAS allows this to be NULL for built-in types.
+     149          52 :             GrB_Type ctype = NULL ;
+     150          52 :             LG_TRY (LAGraph_TypeFromName (&ctype, Contents [i].type_name, msg));
+     151          52 :             GRB_TRY (GrB_Matrix_deserialize (&(Set [kmatrices]), ctype, blob,
+     152             :                 blob_size)) ;
+     153          52 :             kmatrices++ ;
+     154             :         }
+     155             :         // todo: handle vectors and texts
+     156             :         // else if (Content [i].kind == LAGraph_vector_kind) ...
+     157             :         // else if (Content [i].kind == LAGraph_text_kind) ...
+     158             : 
+     159             :         // free the ith blob
+     160          52 :         LAGraph_Free ((void **) &(Contents [i].blob), NULL) ;
+     161             :     }
+     162             : 
+     163             :     //--------------------------------------------------------------------------
+     164             :     // free workspace and return result
+     165             :     //--------------------------------------------------------------------------
+     166             : 
+     167           2 :     LG_FREE_WORK ;
+     168           2 :     (*Set_handle) = Set ;
+     169           2 :     (*collection_handle) = collection ;
+     170           2 :     (*nmatrices_handle) = nmatrices ;
+     171           2 :     return (GrB_SUCCESS) ;
+     172             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/utility/LAGraph_SRead.c.func-sort-c.html b/experimental/utility/LAGraph_SRead.c.func-sort-c.html new file mode 100644 index 0000000000..edcbaaa1bd --- /dev/null +++ b/experimental/utility/LAGraph_SRead.c.func-sort-c.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/utility/LAGraph_SRead.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/utility - LAGraph_SRead.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:117117100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_SRead208
get_int_array_3416
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/utility/LAGraph_SRead.c.func.html b/experimental/utility/LAGraph_SRead.c.func.html new file mode 100644 index 0000000000..3595ef42cc --- /dev/null +++ b/experimental/utility/LAGraph_SRead.c.func.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/utility/LAGraph_SRead.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/utility - LAGraph_SRead.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:117117100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_SRead208
get_int_array_3416
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/utility/LAGraph_SRead.c.gcov.html b/experimental/utility/LAGraph_SRead.c.gcov.html new file mode 100644 index 0000000000..030115a755 --- /dev/null +++ b/experimental/utility/LAGraph_SRead.c.gcov.html @@ -0,0 +1,450 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/utility/LAGraph_SRead.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/utility - LAGraph_SRead.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:117117100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_SRead: read a sequence of serialized objects from a file
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // LAGraph_SRead reads a set of serialized items from a file. The items are
+      19             : // returned as-is and not converted into GrB_Matrix, GrB_Vector, or text
+      20             : // objects.  The user application is responsible for freeing the output of this
+      21             : // method, via:
+      22             : 
+      23             : //      LAGraph_Free ((void **) &collection, NULL) ;
+      24             : //      LAGraph_SFreeContents (&Contents, ncontents) ;
+      25             : 
+      26             : // See also LAGraph_SLoadSet, which calls this function and then converts all
+      27             : // serialized objects into their GrB_Matrix, GrB_Vector, or text components.
+      28             : 
+      29             : //------------------------------------------------------------------------------
+      30             : 
+      31             : #include "LG_internal.h"
+      32             : #include "LAGraphX.h"
+      33             : 
+      34             : //------------------------------------------------------------------------------
+      35             : // json.h: JSON parser
+      36             : //------------------------------------------------------------------------------
+      37             : 
+      38             : #include "json.h"
+      39             : 
+      40             : typedef struct json_value_s  *json_val ;
+      41             : typedef struct json_object_s *json_obj ; // { json_o start; size length }
+      42             : typedef struct json_array_s  *json_arr ; // { json_a start; size length }
+      43             : typedef struct json_string_s *json_str ; // { char *string; size string_size }
+      44             : typedef struct json_number_s *json_num ; // { char *number; size number_size }
+      45             : 
+      46             : // object element: { char *name; json_val value ; json_o next }
+      47             : typedef struct json_object_element_s *json_o ;
+      48             : 
+      49             : // array element:  {             json_val value ; json_a next }
+      50             : typedef struct json_array_element_s  *json_a ;
+      51             : 
+      52             : #define STRMATCH(s,t) (strcmp (s,t) == 0)
+      53             : #define OK(ok) LG_ASSERT_MSG (ok, LAGRAPH_IO_ERROR, "invalid file")
+      54             : #define VER(major,minor,sub) (((major)*1000ULL + (minor))*1000ULL + (sub))
+      55             : 
+      56             : //------------------------------------------------------------------------------
+      57             : // get_int_array_3: get an int array of size 3 from the JSON header
+      58             : //------------------------------------------------------------------------------
+      59             : 
+      60         416 : static int get_int_array_3 (json_arr arr, int *x, char *msg)
+      61             : {
+      62         416 :     OK (arr != NULL) ;
+      63         416 :     OK (x != NULL) ;
+      64         416 :     OK (arr->length == 3) ;
+      65         416 :     json_a a = arr->start ;
+      66         416 :     json_num num = json_value_as_number (a->value) ;
+      67         416 :     OK (num != NULL) ;
+      68         416 :     x [0] = (int) strtol (num->number, NULL, 0) ;
+      69         416 :     a = a->next ;
+      70         416 :     num = json_value_as_number (a->value) ;
+      71         416 :     OK (num != NULL) ;
+      72         416 :     x [1] = (int) strtol (num->number, NULL, 0) ;
+      73         416 :     a = a->next ;
+      74         416 :     num = json_value_as_number (a->value) ;
+      75         416 :     OK (num != NULL) ;
+      76         416 :     x [2] = (int) strtol (num->number, NULL, 0) ;
+      77         416 :     return (GrB_SUCCESS) ;
+      78             : }
+      79             : 
+      80             : //------------------------------------------------------------------------------
+      81             : // LAGraph_SRead
+      82             : //------------------------------------------------------------------------------
+      83             : 
+      84             : #undef  LG_FREE_WORK
+      85             : #define LG_FREE_WORK                                    \
+      86             : {                                                       \
+      87             :     if (root != NULL) { free (root) ; }                 \
+      88             :     root = NULL ;                                       \
+      89             :     LAGraph_Free ((void **) &json_string, NULL) ;       \
+      90             : }
+      91             : 
+      92             : #undef  LG_FREE_ALL
+      93             : #define LG_FREE_ALL                                     \
+      94             : {                                                       \
+      95             :     LG_FREE_WORK ;                                      \
+      96             :     LAGraph_Free ((void **) &collection, NULL) ;        \
+      97             :     LAGraph_SFreeContents (&Contents, ncontents) ;      \
+      98             : }
+      99             : 
+     100         208 : int LAGraph_SRead   // read a set of matrices from a *.lagraph file
+     101             : (
+     102             :     FILE *f,                            // file to read from
+     103             :     // output
+     104             :     char **collection_handle,           // name of collection
+     105             :     LAGraph_Contents **Contents_handle, // array of contents
+     106             :     GrB_Index *ncontents_handle,        // # of items in the Contents array
+     107             :     char *msg
+     108             : )
+     109             : {
+     110             : 
+     111             :     //--------------------------------------------------------------------------
+     112             :     // check inputs
+     113             :     //--------------------------------------------------------------------------
+     114             : 
+     115         208 :     LG_CLEAR_MSG ;
+     116         208 :     char *json_string = NULL ;
+     117         208 :     json_val root = NULL ;
+     118         208 :     char *collection = NULL ;
+     119         208 :     LAGraph_Contents *Contents = NULL ;
+     120         208 :     GrB_Index ncontents = 0 ;
+     121             : 
+     122         208 :     LG_ASSERT (collection_handle != NULL, GrB_NULL_POINTER) ;
+     123         208 :     LG_ASSERT (Contents_handle != NULL, GrB_NULL_POINTER) ;
+     124         208 :     LG_ASSERT (f != NULL, GrB_NULL_POINTER) ;
+     125         208 :     LG_ASSERT (ncontents_handle != NULL, GrB_NULL_POINTER) ;
+     126         208 :     (*collection_handle) = NULL ;
+     127         208 :     (*Contents_handle) = NULL ;
+     128         208 :     (*ncontents_handle) = 0 ;
+     129             : 
+     130             :     //--------------------------------------------------------------------------
+     131             :     // load in a json string from the file
+     132             :     //--------------------------------------------------------------------------
+     133             : 
+     134         208 :     size_t s = 256, k = 0 ;
+     135         208 :     LAGRAPH_TRY (LAGraph_Malloc ((void **) &json_string, s, sizeof (char),
+     136             :         msg)) ;
+     137             :     while (true)
+     138       43028 :     {
+     139       43236 :         if (k == s)
+     140             :         {
+     141             :             // json_string is full; double its size
+     142           4 :             LG_TRY (LAGraph_Realloc ((void **) &json_string, 2*s, s,
+     143             :                 sizeof (char), msg)) ;
+     144           4 :             s = 2*s ;
+     145             :         }
+     146             :         // get the next character from the file
+     147       43236 :         int c = fgetc (f) ;
+     148       43236 :         if (c == EOF || c == '\0')
+     149             :         {
+     150             :             // end of the JSON string; remainder is matrix/vector/text data
+     151         208 :             json_string [k] = '\0' ;
+     152         208 :             break ;
+     153             :         }
+     154       43028 :         json_string [k++] = (char) c ;
+     155             :     }
+     156             : 
+     157             :     //--------------------------------------------------------------------------
+     158             :     // parse the json string and free it
+     159             :     //--------------------------------------------------------------------------
+     160             : 
+     161         208 :     root = json_parse (json_string, k) ;
+     162         208 :     LG_ASSERT (root != NULL, GrB_OUT_OF_MEMORY) ;
+     163         208 :     LAGraph_Free ((void **) &json_string, NULL) ;
+     164             : 
+     165             :     //--------------------------------------------------------------------------
+     166             :     // process the JSON header
+     167             :     //--------------------------------------------------------------------------
+     168             : 
+     169         208 :     json_obj obj = json_value_as_object (root) ;
+     170         208 :     json_o o = obj->start ;
+     171         208 :     json_a a = NULL ;
+     172         208 :     json_arr arr = NULL ;
+     173         208 :     json_str str = NULL ;
+     174             : 
+     175             :     //--------------------------------------------------------------------------
+     176             :     // check LAGraph version
+     177             :     //--------------------------------------------------------------------------
+     178             : 
+     179         208 :     arr = json_value_as_array (o->value) ;
+     180             :     int lagraph_version [3] ;
+     181         208 :     int result = get_int_array_3 (arr, lagraph_version, msg) ;
+     182         208 :     OK (result == GrB_SUCCESS) ;
+     183         208 :     OK (VER (lagraph_version [0], lagraph_version [1], lagraph_version [2])
+     184             :      <= VER (LAGRAPH_VERSION_MAJOR, LAGRAPH_VERSION_MINOR,
+     185             :              LAGRAPH_VERSION_UPDATE)) ;
+     186             : 
+     187             :     //--------------------------------------------------------------------------
+     188             :     // check GraphBLAS library name and version
+     189             :     //--------------------------------------------------------------------------
+     190             : 
+     191         208 :     o = o->next ;
+     192         208 :     OK (STRMATCH (o->name->string, "GraphBLAS")) ;
+     193         208 :     arr = json_value_as_array (o->value) ;
+     194         208 :     OK (arr->length == 2) ;
+     195         208 :     a = arr->start ;
+     196         208 :     str = json_value_as_string (a->value) ;
+     197             :     #if LAGRAPH_SUITESPARSE
+     198         208 :     OK (STRMATCH (str->string, "SuiteSparse:GraphBLAS")) ;
+     199             :     #else
+     200             :     OK (STRMATCH (str->string, "vanilla")) ;
+     201             :     #endif
+     202         208 :     a = a->next ;
+     203         208 :     arr = json_value_as_array (a->value) ;
+     204             : 
+     205             :     int graphblas_version [3] ;
+     206         208 :     result = get_int_array_3 (arr, graphblas_version, msg) ;
+     207         208 :     OK (result == GrB_SUCCESS) ;
+     208         208 :     uint64_t library_version =
+     209         208 :         VER (graphblas_version [0],
+     210             :              graphblas_version [1],
+     211             :              graphblas_version [2]) ;
+     212             :     #if LAGRAPH_SUITESPARSE
+     213         208 :     OK (library_version <= GxB_IMPLEMENTATION) ;
+     214             :     #else
+     215             :     OK (library_version <= VER (1,0,0)) ;
+     216             :     #endif
+     217             : 
+     218             :     //--------------------------------------------------------------------------
+     219             :     // get the contents and the name of the collection
+     220             :     //--------------------------------------------------------------------------
+     221             : 
+     222         208 :     o = o->next ;
+     223         208 :     OK (o->value->type == json_type_array) ;
+     224         208 :     size_t len = o->name->string_size ;
+     225         208 :     LG_TRY (LAGraph_Calloc ((void **) &collection, len+1, sizeof (char), msg)) ;
+     226         208 :     strncpy (collection, o->name->string, len) ;
+     227             : 
+     228             :     //--------------------------------------------------------------------------
+     229             :     // iterate over the contents
+     230             :     //--------------------------------------------------------------------------
+     231             : 
+     232         208 :     arr = json_value_as_array (o->value) ;
+     233         208 :     OK (arr != NULL) ;
+     234         208 :     a = arr->start ;
+     235         208 :     len = arr->length ;
+     236             :     // allocate an Contents array of size len to hold the contents
+     237         208 :     LG_TRY (LAGraph_Calloc ((void **) &Contents, len, sizeof (LAGraph_Contents),
+     238             :         msg)) ;
+     239             : 
+     240         464 :     for (int i = 0 ; i < len && a != NULL ; i++, a = a->next)
+     241             :     {
+     242             : 
+     243             :         //----------------------------------------------------------------------
+     244             :         // get the next item
+     245             :         //----------------------------------------------------------------------
+     246             : 
+     247         464 :         if (a->value->type == json_type_null) break ;
+     248         258 :         ncontents++ ;
+     249         258 :         LAGraph_Contents *Item = &(Contents [i]) ;
+     250         258 :         OK (a != NULL) ;
+     251         258 :         OK (a->value->type == json_type_object) ;
+     252         258 :         json_obj obj = json_value_as_object (a->value) ;
+     253         258 :         OK (obj != NULL) ;
+     254         258 :         json_o o = obj->start ;
+     255         258 :         OK (o != NULL) ;
+     256         258 :         OK (o->value->type == json_type_string) ;
+     257         258 :         int len = obj->length ;
+     258         258 :         OK (len == 3) ;
+     259             : 
+     260             :         //----------------------------------------------------------------------
+     261             :         // parse the item kind: matrix, vector, or ascii text
+     262             :         //----------------------------------------------------------------------
+     263             : 
+     264         258 :         if (STRMATCH (o->name->string, "GrB_Matrix"))
+     265             :         {
+     266         256 :             Item->kind = LAGraph_matrix_kind ;
+     267             :         }
+     268             : #if 0
+     269             :         // todo: handle vectors and text
+     270             :         else if (STRMATCH (o->name->string, "GrB_Vector"))
+     271             :         {
+     272             :             Item->kind = LAGraph_vector_kind ;
+     273             :         }
+     274             :         else if (STRMATCH (o->name->string, "text"))
+     275             :         {
+     276             :             Item->kind = LAGraph_text_kind ;
+     277             :         }
+     278             : #endif
+     279             :         else
+     280             :         {
+     281           2 :             Item->kind = LAGraph_unknown_kind ;
+     282           2 :             OK (false) ;
+     283             :         }
+     284             : 
+     285             :         //----------------------------------------------------------------------
+     286             :         // parse the item name
+     287             :         //----------------------------------------------------------------------
+     288             : 
+     289         256 :         json_str str = json_value_as_string (o->value) ;
+     290         256 :         strncpy (Item->name, str->string, LAGRAPH_MAX_NAME_LEN) ;
+     291         256 :         Item->name [LAGRAPH_MAX_NAME_LEN+1] = '\0' ;
+     292         256 :         OK (str != NULL) ;
+     293         256 :         o = o->next ;
+     294         256 :         str = json_value_as_string (o->value) ;
+     295         256 :         OK (str != NULL) ;
+     296             : 
+     297             :         //----------------------------------------------------------------------
+     298             :         // parse the text compression method, or matrix/vector type
+     299             :         //----------------------------------------------------------------------
+     300             : 
+     301             : #if 0
+     302             :         // todo: handle text, with optional compression
+     303             :         if (Item->kind == LAGraph_text_kind)
+     304             :         {
+     305             :             // text, uncompressed or compressed
+     306             :             int c ;
+     307             :             if      (STRMATCH (str->string, "none"   )) c = -1 ;
+     308             :             else if (STRMATCH (str->string, "default")) c = 0 ;
+     309             :             else if (STRMATCH (str->string, "lz4"    )) c = 1000 ;
+     310             :             else if (STRMATCH (str->string, "lz4hc:0")) c = 2000 ;
+     311             :             else if (STRMATCH (str->string, "lz4hc:1")) c = 2001 ;
+     312             :             else if (STRMATCH (str->string, "lz4hc:2")) c = 2002 ;
+     313             :             else if (STRMATCH (str->string, "lz4hc:3")) c = 2003 ;
+     314             :             else if (STRMATCH (str->string, "lz4hc:4")) c = 2004 ;
+     315             :             else if (STRMATCH (str->string, "lz4hc:5")) c = 2005 ;
+     316             :             else if (STRMATCH (str->string, "lz4hc:6")) c = 2006 ;
+     317             :             else if (STRMATCH (str->string, "lz4hc:7")) c = 2007 ;
+     318             :             else if (STRMATCH (str->string, "lz4hc:8")) c = 2008 ;
+     319             :             else if (STRMATCH (str->string, "lz4hc:9")) c = 2009 ;
+     320             :             else OK (false) ;
+     321             :             Item->type_name [0] = '\0' ;    // or set to "char"?
+     322             :             Item->compression = c ;
+     323             :         }
+     324             :         else
+     325             : #endif
+     326             :         {
+     327             :             // serialized matrix or vector
+     328         256 :             strncpy (Item->type_name, str->string, LAGRAPH_MAX_NAME_LEN) ;
+     329         256 :             Item->type_name [LAGRAPH_MAX_NAME_LEN+1] = '\0' ;
+     330         256 :             Item->compression = 0 ;
+     331             :         }
+     332             : 
+     333             :         //----------------------------------------------------------------------
+     334             :         // parse the item size
+     335             :         //----------------------------------------------------------------------
+     336             : 
+     337         256 :         o = o->next ;
+     338         256 :         json_num num = json_value_as_number (o->value) ;
+     339         256 :         OK (num != NULL) ;
+     340         256 :         Item->blob_size = (GrB_Index) strtoll (num->number, NULL, 0) ;
+     341             : 
+     342             :         //----------------------------------------------------------------------
+     343             :         // allocate the blob and read it from the file
+     344             :         //----------------------------------------------------------------------
+     345             : 
+     346         256 :         LAGRAPH_TRY (LAGraph_Malloc ((void **) &(Item->blob), Item->blob_size,
+     347             :             sizeof (uint8_t), msg)) ;
+     348         256 :         size_t bytes_read = fread (Item->blob, sizeof (uint8_t),
+     349             :             Item->blob_size, f) ;
+     350         256 :         OK (bytes_read == Item->blob_size) ;
+     351             :     }
+     352             : 
+     353             :     // todo: optional components will be needed for matrices from
+     354             :     // sparse.tamu.edu (matrix id, author, editor, title, etc)
+     355             : #if 0
+     356             :     // optional components
+     357             :     o = o->next ;
+     358             :     while (o != NULL)
+     359             :     {
+     360             :         printf ("other: [%s]\n", o->name->string) ;
+     361             :         o = o->next ;
+     362             :     }
+     363             : #endif
+     364             : 
+     365             :     //--------------------------------------------------------------------------
+     366             :     // free workspace and return result
+     367             :     //--------------------------------------------------------------------------
+     368             : 
+     369         206 :     LG_FREE_WORK  ;
+     370         206 :     (*collection_handle) = collection ;
+     371         206 :     (*Contents_handle) = Contents ;
+     372         206 :     (*ncontents_handle) = ncontents ;
+     373         206 :     return (GrB_SUCCESS) ;
+     374             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/utility/LAGraph_SSaveSet.c.func-sort-c.html b/experimental/utility/LAGraph_SSaveSet.c.func-sort-c.html new file mode 100644 index 0000000000..89a051fe38 --- /dev/null +++ b/experimental/utility/LAGraph_SSaveSet.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/utility/LAGraph_SSaveSet.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/utility - LAGraph_SSaveSet.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:2323100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_SSaveSet1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/utility/LAGraph_SSaveSet.c.func.html b/experimental/utility/LAGraph_SSaveSet.c.func.html new file mode 100644 index 0000000000..59b4e5ee1c --- /dev/null +++ b/experimental/utility/LAGraph_SSaveSet.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/utility/LAGraph_SSaveSet.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/utility - LAGraph_SSaveSet.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:2323100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_SSaveSet1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/utility/LAGraph_SSaveSet.c.gcov.html b/experimental/utility/LAGraph_SSaveSet.c.gcov.html new file mode 100644 index 0000000000..c7a7a167df --- /dev/null +++ b/experimental/utility/LAGraph_SSaveSet.c.gcov.html @@ -0,0 +1,222 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/utility/LAGraph_SSaveSet.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/utility - LAGraph_SSaveSet.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:2323100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_SSaveSet: save a set of matrices to a *.lagraph file
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // LAGraph_SSaveSet saves a set of matrices to a *.lagraph file.
+      19             : // The file is created, written to with the JSON header and the serialized
+      20             : // matrices, and then closed.  If using SuiteSparse:GraphBLAS, the highest
+      21             : // level of compression is used (LZ4HC:9).
+      22             : 
+      23             : // Use LAGraph_SSLoadSet to load the matrices back in from the file.
+      24             : 
+      25             : // This method will not work without SuiteSparse:GraphBLAS, because the C API
+      26             : // has no GrB* method for querying the GrB_Type (or its name as a string) of a
+      27             : // matrix.
+      28             : 
+      29             : //------------------------------------------------------------------------------
+      30             : 
+      31             : #define LG_FREE_WORK                                \
+      32             : {                                                   \
+      33             :     fclose (f) ;                                    \
+      34             :     f = NULL ;                                      \
+      35             :     GrB_free (&desc) ;                              \
+      36             :     LAGraph_SFreeContents (&Contents, nmatrices) ;  \
+      37             : }
+      38             : 
+      39             : #define LG_FREE_ALL                                 \
+      40             : {                                                   \
+      41             :     LG_FREE_WORK ;                                  \
+      42             : }
+      43             : 
+      44             : #include "LG_internal.h"
+      45             : #include "LAGraphX.h"
+      46             : 
+      47             : //------------------------------------------------------------------------------
+      48             : // LAGraph_SSaveSet
+      49             : //------------------------------------------------------------------------------
+      50             : 
+      51           1 : int LAGraph_SSaveSet            // save a set of matrices from a *.lagraph file
+      52             : (
+      53             :     // inputs:
+      54             :     char *filename,             // name of file to write to
+      55             :     GrB_Matrix *Set,            // array of GrB_Matrix of size nmatrices
+      56             :     GrB_Index nmatrices,        // # of matrices to write to *.lagraph file
+      57             :     char *collection,           // name of this collection of matrices
+      58             :     char *msg
+      59             : )
+      60             : {
+      61             : 
+      62             :     //--------------------------------------------------------------------------
+      63             :     // check inputs
+      64             :     //--------------------------------------------------------------------------
+      65             : 
+      66           1 :     LG_CLEAR_MSG ;
+      67           1 :     FILE *f = NULL ;
+      68             : 
+      69           1 :     LAGraph_Contents *Contents = NULL ;
+      70           1 :     GrB_Descriptor desc = NULL ;
+      71             : 
+      72           1 :     LG_ASSERT (filename != NULL && Set != NULL && collection != NULL,
+      73             :         GrB_NULL_POINTER) ;
+      74             : 
+      75             :     #if LAGRAPH_SUITESPARSE
+      76           1 :     GRB_TRY (GrB_Descriptor_new (&desc)) ;
+      77           1 :     GRB_TRY (GxB_set (desc, GxB_COMPRESSION, GxB_COMPRESSION_LZ4HC + 9)) ;
+      78             :     #endif
+      79             : 
+      80           1 :     f = fopen (filename, "wb") ;
+      81           1 :     LG_ASSERT_MSG (f != NULL, -1001, "unable to create output file") ;
+      82             : 
+      83             :     //--------------------------------------------------------------------------
+      84             :     // serialize all the matrices
+      85             :     //--------------------------------------------------------------------------
+      86             : 
+      87             :     // allocate an Contents array of size nmatrices to hold the contents
+      88           1 :     LG_TRY (LAGraph_Calloc ((void **) &Contents, nmatrices,
+      89             :         sizeof (LAGraph_Contents), msg)) ;
+      90             : 
+      91          52 :     for (GrB_Index i = 0 ; i < nmatrices ; i++)
+      92             :     {
+      93             :         #if LAGRAPH_SUITESPARSE
+      94             :         {
+      95          51 :             GRB_TRY (GxB_Matrix_serialize (&(Contents [i].blob),
+      96             :                 (GrB_Index *)&(Contents [i].blob_size), Set [i], desc)) ;
+      97             :         }
+      98             :         #else
+      99             :         {
+     100             :             GrB_Index estimate ;
+     101             :             GRB_TRY (GrB_Matrix_serializeSize (&estimate, Set [i])) ;
+     102             :             Contents [i].blob_size = estimate ;
+     103             :             LAGRAPH_TRY (LAGraph_Malloc ((void **) &(Contents [i].blob),
+     104             :                 estimate, sizeof (uint8_t), msg)) ;
+     105             :             GRB_TRY (GrB_Matrix_serialize (Contents [i].blob,
+     106             :                 (GrB_Index *) &(Contents [i].blob_size), Set [i])) ;
+     107             :             LG_TRY (LAGraph_Realloc ((void **) &(Contents [i].blob),
+     108             :                 (size_t) Contents [i].blob_size,
+     109             :                 estimate, sizeof (uint8_t), msg)) ;
+     110             :         }
+     111             :         #endif
+     112             :     }
+     113             : 
+     114             :     //--------------------------------------------------------------------------
+     115             :     // write the header
+     116             :     //--------------------------------------------------------------------------
+     117             : 
+     118           1 :     LG_TRY (LAGraph_SWrite_HeaderStart (f, collection, msg)) ;
+     119          52 :     for (GrB_Index i = 0 ; i < nmatrices ; i++)
+     120             :     {
+     121             :         char typename [GxB_MAX_NAME_LEN] ;
+     122          51 :         LG_TRY (LAGraph_Matrix_TypeName (typename, Set [i], msg)) ;
+     123             :         char matrix_name [256] ;
+     124          51 :         snprintf (matrix_name, 256, "A_%" PRIu64, i) ;
+     125          51 :         LG_TRY (LAGraph_SWrite_HeaderItem (f, LAGraph_matrix_kind,
+     126             :             matrix_name, typename, 0, Contents [i].blob_size, msg)) ;
+     127             :     }
+     128           1 :     LG_TRY (LAGraph_SWrite_HeaderEnd (f, msg)) ;
+     129             : 
+     130             :     //--------------------------------------------------------------------------
+     131             :     // write all the blobs
+     132             :     //--------------------------------------------------------------------------
+     133             : 
+     134          52 :     for (GrB_Index i = 0 ; i < nmatrices ; i++)
+     135             :     {
+     136          51 :         LG_TRY (LAGraph_SWrite_Item (f, Contents [i].blob,
+     137             :             Contents [i].blob_size, msg)) ;
+     138             :     }
+     139             : 
+     140             :     //--------------------------------------------------------------------------
+     141             :     // free workspace and return result
+     142             :     //--------------------------------------------------------------------------
+     143             : 
+     144           1 :     LG_FREE_WORK ;
+     145           1 :     return (GrB_SUCCESS) ;
+     146             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/utility/LAGraph_SWrite.c.func-sort-c.html b/experimental/utility/LAGraph_SWrite.c.func-sort-c.html new file mode 100644 index 0000000000..2aa6acd9cc --- /dev/null +++ b/experimental/utility/LAGraph_SWrite.c.func-sort-c.html @@ -0,0 +1,88 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/utility/LAGraph_SWrite.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/utility - LAGraph_SWrite.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3333100.0 %
Date:2024-08-29 20:08:04Functions:44100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_SWrite_HeaderEnd207
LAGraph_SWrite_HeaderStart208
LAGraph_SWrite_Item258
LAGraph_SWrite_HeaderItem259
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/utility/LAGraph_SWrite.c.func.html b/experimental/utility/LAGraph_SWrite.c.func.html new file mode 100644 index 0000000000..1c7df89c63 --- /dev/null +++ b/experimental/utility/LAGraph_SWrite.c.func.html @@ -0,0 +1,88 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/utility/LAGraph_SWrite.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/utility - LAGraph_SWrite.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3333100.0 %
Date:2024-08-29 20:08:04Functions:44100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_SWrite_HeaderEnd207
LAGraph_SWrite_HeaderItem259
LAGraph_SWrite_HeaderStart208
LAGraph_SWrite_Item258
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/utility/LAGraph_SWrite.c.gcov.html b/experimental/utility/LAGraph_SWrite.c.gcov.html new file mode 100644 index 0000000000..35d95b8515 --- /dev/null +++ b/experimental/utility/LAGraph_SWrite.c.gcov.html @@ -0,0 +1,256 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/utility/LAGraph_SWrite.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/utility - LAGraph_SWrite.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3333100.0 %
Date:2024-08-29 20:08:04Functions:44100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_SWrite: write a sequence of serialized objects to a file
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include "LG_internal.h"
+      19             : #include "LAGraphX.h"
+      20             : 
+      21             : #define FPRINT(params)                                  \
+      22             : {                                                       \
+      23             :     int result = fprintf params ;                       \
+      24             :     LG_ASSERT_MSG (result >= 0, -1002, "file not written") ;  \
+      25             : }
+      26             : 
+      27             : //------------------------------------------------------------------------------
+      28             : // LAGraph_SWrite_HeaderStart
+      29             : //------------------------------------------------------------------------------
+      30             : 
+      31         208 : int LAGraph_SWrite_HeaderStart  // write the first part of the JSON header
+      32             : (
+      33             :     FILE *f,                    // file to write to
+      34             :     const char *name,           // name of this collection of matrices
+      35             :     char *msg
+      36             : )
+      37             : {
+      38             :     // check inputs
+      39         208 :     LG_CLEAR_MSG ;
+      40         208 :     LG_ASSERT (f != NULL && name != NULL, GrB_NULL_POINTER) ;
+      41             : 
+      42             :     // write the first part of the JSON header to the file
+      43         206 :     FPRINT ((f, "{\n    \"LAGraph\": [%d,%d,%d],\n    \"GraphBLAS\": [ ",
+      44             :         LAGRAPH_VERSION_MAJOR, LAGRAPH_VERSION_MINOR, LAGRAPH_VERSION_UPDATE)) ;
+      45             : 
+      46             :     #if LAGRAPH_SUITESPARSE
+      47             : 
+      48             :         // SuiteSparse:GraphBLAS v6.0.0 or later
+      49             :         char *library ;
+      50             :         int ver [3] ;
+      51         206 :         GRB_TRY (GxB_get (GxB_LIBRARY_NAME, &library)) ;
+      52         206 :         GRB_TRY (GxB_get (GxB_LIBRARY_VERSION, ver)) ;
+      53         206 :         FPRINT ((f, "\"%s\", [%d,%d,%d] ],\n", library,
+      54             :             ver [0], ver [1], ver [2])) ;
+      55             : 
+      56             :     #else
+      57             : 
+      58             :         // some other GraphBLAS library: call it "vanilla 1.0.0"
+      59             :         FPRINT ((f, "\"%s\", [%d,%d,%d] ],\n", "vanilla", 1, 0, 0)) ;
+      60             : 
+      61             :     #endif
+      62             : 
+      63             :     // write name of this collection and start the list of items
+      64         206 :     FPRINT ((f, "    \"%s\":\n    [\n", name)) ;
+      65         206 :     return (GrB_SUCCESS) ;
+      66             : }
+      67             : 
+      68             : //------------------------------------------------------------------------------
+      69             : // LAGraph_SWrite_HeaderItem
+      70             : //------------------------------------------------------------------------------
+      71             : 
+      72         259 : int LAGraph_SWrite_HeaderItem   // write a single item to the JSON header
+      73             : (
+      74             :     // inputs:
+      75             :     FILE *f,                    // file to write to
+      76             :     LAGraph_Contents_kind kind, // matrix, vector, or text
+      77             :     const char *name,           // name of the matrix/vector/text; matrices from
+      78             :                                 // sparse.tamu.edu use the form "Group/Name"
+      79             :     const char *type,           // name of type of the matrix/vector
+      80             :     // todo: vectors and text not yet supported by LAGraph_SWrite_HeaderItem
+      81             :     int compression,            // text compression method
+      82             :     GrB_Index blob_size,        // exact size of serialized blob for this item
+      83             :     char *msg
+      84             : )
+      85             : {
+      86             :     // check inputs
+      87         259 :     LG_CLEAR_MSG ;
+      88         259 :     LG_ASSERT (f != NULL, GrB_NULL_POINTER) ;
+      89             : 
+      90             :     // write the JSON information for this item
+      91         257 :     FPRINT ((f, "        { \"")) ;
+      92         257 :     switch (kind)
+      93             :     {
+      94         256 :         case LAGraph_matrix_kind :
+      95         256 :             FPRINT ((f, "GrB_Matrix\": \"%s\", \"type\": \"%s", name, type)) ;
+      96         256 :             break ;
+      97             : 
+      98             :         // todo: handle vectors and text
+      99             : #if 0
+     100             :         case LAGraph_vector_kind :
+     101             :             FPRINT((f, "GrB_Vector\": \"%s\", \"type\": \"%s", name, type)) ;
+     102             :             break ;
+     103             : 
+     104             :         case LAGraph_text_kind :
+     105             :             FPRINT ((f, "text\": \"%s\", \"compression\": \"", name)) ;
+     106             :             switch (compression)
+     107             :             {
+     108             :                 case -1   : FPRINT ((f, "none"   )) ; break ;
+     109             :                 case 0    : FPRINT ((f, "default")) ; break ;
+     110             :                 case 1000 : FPRINT ((f, "lz4"    )) ; break ;
+     111             :                 case 2000 : FPRINT ((f, "lz4hc:0")) ; break ;
+     112             :                 case 2001 : FPRINT ((f, "lz4hc:1")) ; break ;
+     113             :                 case 2002 : FPRINT ((f, "lz4hc:2")) ; break ;
+     114             :                 case 2003 : FPRINT ((f, "lz4hc:3")) ; break ;
+     115             :                 case 2004 : FPRINT ((f, "lz4hc:4")) ; break ;
+     116             :                 case 2005 : FPRINT ((f, "lz4hc:5")) ; break ;
+     117             :                 case 2006 : FPRINT ((f, "lz4hc:6")) ; break ;
+     118             :                 case 2007 : FPRINT ((f, "lz4hc:7")) ; break ;
+     119             :                 case 2008 : FPRINT ((f, "lz4hc:8")) ; break ;
+     120             :                 case 2009 : FPRINT ((f, "lz4hc:9")) ; break ;
+     121             :                 default   : LG_ASSERT_MSG (false, GrB_INVALID_VALUE,
+     122             :                     "invalid compression") ; break ;
+     123             :             }
+     124             :             break ;
+     125             : #endif
+     126             : 
+     127           1 :         default :
+     128           1 :             LG_ASSERT_MSG (false, GrB_INVALID_VALUE, "invalid kind") ;
+     129             :             break ;
+     130             :     }
+     131             : 
+     132         256 :     FPRINT ((f, "\", \"bytes\": %" PRIu64 " },\n", blob_size)) ;
+     133         256 :     return (GrB_SUCCESS) ;
+     134             : }
+     135             : 
+     136             : //------------------------------------------------------------------------------
+     137             : // LAGraph_SWrite_HeaderEnd
+     138             : //------------------------------------------------------------------------------
+     139             : 
+     140         207 : int LAGraph_SWrite_HeaderEnd    // write the end of the JSON header
+     141             : (
+     142             :     FILE *f,                    // file to write to
+     143             :     char *msg
+     144             : )
+     145             : {
+     146             :     // check inputs
+     147         207 :     LG_CLEAR_MSG ;
+     148         207 :     LG_ASSERT (f != NULL, GrB_NULL_POINTER) ;
+     149             : 
+     150             :     // finalize the JSON header string
+     151         206 :     FPRINT ((f, "        null\n    ]\n}\n")) ;
+     152             : 
+     153             :     // write a final zero byte to terminate the JSON string
+     154         206 :     fputc (0, f) ;
+     155         206 :     return (GrB_SUCCESS) ;
+     156             : }
+     157             : 
+     158             : //------------------------------------------------------------------------------
+     159             : // LAGraph_SWrite_Item
+     160             : //------------------------------------------------------------------------------
+     161             : 
+     162         258 : int LAGraph_SWrite_Item  // write the serialized blob of a matrix/vector/text
+     163             : (
+     164             :     // input:
+     165             :     FILE *f,                // file to write to
+     166             :     const void *blob,       // serialized blob from G*B_Matrix_serialize
+     167             :     GrB_Index blob_size,    // exact size of the serialized blob
+     168             :     char *msg
+     169             : )
+     170             : {
+     171             :     // check inputs
+     172         258 :     LG_CLEAR_MSG ;
+     173         258 :     LG_ASSERT (f != NULL && blob != NULL, GrB_NULL_POINTER) ;
+     174             : 
+     175             :     // write the blob
+     176         256 :     size_t blob_written = fwrite (blob, sizeof (uint8_t), blob_size, f) ;
+     177         256 :     LG_ASSERT_MSG (blob_written == blob_size, -1001,
+     178             :         "file not written properly") ;
+     179         256 :     return (GrB_SUCCESS) ;
+     180             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/utility/index-sort-f.html b/experimental/utility/index-sort-f.html new file mode 100644 index 0000000000..659532b0f4 --- /dev/null +++ b/experimental/utility/index-sort-f.html @@ -0,0 +1,163 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/utility + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/utilityHitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:343343100.0 %
Date:2024-08-29 20:08:04Functions:1717100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
LAGraph_SLoadSet.c +
100.0%
+
100.0 %33 / 33100.0 %1 / 1
LAGraph_SFreeContents.c +
100.0%
+
100.0 %8 / 8100.0 %1 / 1
LAGraph_SSaveSet.c +
100.0%
+
100.0 %23 / 23100.0 %1 / 1
LAGraph_SFreeSet.c +
100.0%
+
100.0 %8 / 8100.0 %1 / 1
LAGraph_Random_Matrix.c +
100.0%
+
100.0 %84 / 84100.0 %2 / 2
LAGraph_SRead.c +
100.0%
+
100.0 %117 / 117100.0 %2 / 2
LAGraph_SWrite.c +
100.0%
+
100.0 %33 / 33100.0 %4 / 4
LAGraph_Random.c +
100.0%
+
100.0 %37 / 37100.0 %5 / 5
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/utility/index-sort-l.html b/experimental/utility/index-sort-l.html new file mode 100644 index 0000000000..e5879e1f5b --- /dev/null +++ b/experimental/utility/index-sort-l.html @@ -0,0 +1,163 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/utility + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/utilityHitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:343343100.0 %
Date:2024-08-29 20:08:04Functions:1717100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
LAGraph_SFreeContents.c +
100.0%
+
100.0 %8 / 8100.0 %1 / 1
LAGraph_SFreeSet.c +
100.0%
+
100.0 %8 / 8100.0 %1 / 1
LAGraph_SSaveSet.c +
100.0%
+
100.0 %23 / 23100.0 %1 / 1
LAGraph_SLoadSet.c +
100.0%
+
100.0 %33 / 33100.0 %1 / 1
LAGraph_SWrite.c +
100.0%
+
100.0 %33 / 33100.0 %4 / 4
LAGraph_Random.c +
100.0%
+
100.0 %37 / 37100.0 %5 / 5
LAGraph_Random_Matrix.c +
100.0%
+
100.0 %84 / 84100.0 %2 / 2
LAGraph_SRead.c +
100.0%
+
100.0 %117 / 117100.0 %2 / 2
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/experimental/utility/index.html b/experimental/utility/index.html new file mode 100644 index 0000000000..75144ab779 --- /dev/null +++ b/experimental/utility/index.html @@ -0,0 +1,163 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - experimental/utility + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - experimental/utilityHitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:343343100.0 %
Date:2024-08-29 20:08:04Functions:1717100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
LAGraph_Random.c +
100.0%
+
100.0 %37 / 37100.0 %5 / 5
LAGraph_Random_Matrix.c +
100.0%
+
100.0 %84 / 84100.0 %2 / 2
LAGraph_SFreeContents.c +
100.0%
+
100.0 %8 / 8100.0 %1 / 1
LAGraph_SFreeSet.c +
100.0%
+
100.0 %8 / 8100.0 %1 / 1
LAGraph_SLoadSet.c +
100.0%
+
100.0 %33 / 33100.0 %1 / 1
LAGraph_SRead.c +
100.0%
+
100.0 %117 / 117100.0 %2 / 2
LAGraph_SSaveSet.c +
100.0%
+
100.0 %23 / 23100.0 %1 / 1
LAGraph_SWrite.c +
100.0%
+
100.0 %33 / 33100.0 %4 / 4
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/gcov.css b/gcov.css new file mode 100644 index 0000000000..bfd0a83e10 --- /dev/null +++ b/gcov.css @@ -0,0 +1,519 @@ +/* All views: initial background and text color */ +body +{ + color: #000000; + background-color: #FFFFFF; +} + +/* All views: standard link format*/ +a:link +{ + color: #284FA8; + text-decoration: underline; +} + +/* All views: standard link - visited format */ +a:visited +{ + color: #00CB40; + text-decoration: underline; +} + +/* All views: standard link - activated format */ +a:active +{ + color: #FF0040; + text-decoration: underline; +} + +/* All views: main title format */ +td.title +{ + text-align: center; + padding-bottom: 10px; + font-family: sans-serif; + font-size: 20pt; + font-style: italic; + font-weight: bold; +} + +/* All views: header item format */ +td.headerItem +{ + text-align: right; + padding-right: 6px; + font-family: sans-serif; + font-weight: bold; + vertical-align: top; + white-space: nowrap; +} + +/* All views: header item value format */ +td.headerValue +{ + text-align: left; + color: #284FA8; + font-family: sans-serif; + font-weight: bold; + white-space: nowrap; +} + +/* All views: header item coverage table heading */ +td.headerCovTableHead +{ + text-align: center; + padding-right: 6px; + padding-left: 6px; + padding-bottom: 0px; + font-family: sans-serif; + font-size: 80%; + white-space: nowrap; +} + +/* All views: header item coverage table entry */ +td.headerCovTableEntry +{ + text-align: right; + color: #284FA8; + font-family: sans-serif; + font-weight: bold; + white-space: nowrap; + padding-left: 12px; + padding-right: 4px; + background-color: #DAE7FE; +} + +/* All views: header item coverage table entry for high coverage rate */ +td.headerCovTableEntryHi +{ + text-align: right; + color: #000000; + font-family: sans-serif; + font-weight: bold; + white-space: nowrap; + padding-left: 12px; + padding-right: 4px; + background-color: #A7FC9D; +} + +/* All views: header item coverage table entry for medium coverage rate */ +td.headerCovTableEntryMed +{ + text-align: right; + color: #000000; + font-family: sans-serif; + font-weight: bold; + white-space: nowrap; + padding-left: 12px; + padding-right: 4px; + background-color: #FFEA20; +} + +/* All views: header item coverage table entry for ow coverage rate */ +td.headerCovTableEntryLo +{ + text-align: right; + color: #000000; + font-family: sans-serif; + font-weight: bold; + white-space: nowrap; + padding-left: 12px; + padding-right: 4px; + background-color: #FF0000; +} + +/* All views: header legend value for legend entry */ +td.headerValueLeg +{ + text-align: left; + color: #000000; + font-family: sans-serif; + font-size: 80%; + white-space: nowrap; + padding-top: 4px; +} + +/* All views: color of horizontal ruler */ +td.ruler +{ + background-color: #6688D4; +} + +/* All views: version string format */ +td.versionInfo +{ + text-align: center; + padding-top: 2px; + font-family: sans-serif; + font-style: italic; +} + +/* Directory view/File view (all)/Test case descriptions: + table headline format */ +td.tableHead +{ + text-align: center; + color: #FFFFFF; + background-color: #6688D4; + font-family: sans-serif; + font-size: 120%; + font-weight: bold; + white-space: nowrap; + padding-left: 4px; + padding-right: 4px; +} + +span.tableHeadSort +{ + padding-right: 4px; +} + +/* Directory view/File view (all): filename entry format */ +td.coverFile +{ + text-align: left; + padding-left: 10px; + padding-right: 20px; + color: #284FA8; + background-color: #DAE7FE; + font-family: monospace; +} + +/* Directory view/File view (all): bar-graph entry format*/ +td.coverBar +{ + padding-left: 10px; + padding-right: 10px; + background-color: #DAE7FE; +} + +/* Directory view/File view (all): bar-graph outline color */ +td.coverBarOutline +{ + background-color: #000000; +} + +/* Directory view/File view (all): percentage entry for files with + high coverage rate */ +td.coverPerHi +{ + text-align: right; + padding-left: 10px; + padding-right: 10px; + background-color: #A7FC9D; + font-weight: bold; + font-family: sans-serif; +} + +/* Directory view/File view (all): line count entry for files with + high coverage rate */ +td.coverNumHi +{ + text-align: right; + padding-left: 10px; + padding-right: 10px; + background-color: #A7FC9D; + white-space: nowrap; + font-family: sans-serif; +} + +/* Directory view/File view (all): percentage entry for files with + medium coverage rate */ +td.coverPerMed +{ + text-align: right; + padding-left: 10px; + padding-right: 10px; + background-color: #FFEA20; + font-weight: bold; + font-family: sans-serif; +} + +/* Directory view/File view (all): line count entry for files with + medium coverage rate */ +td.coverNumMed +{ + text-align: right; + padding-left: 10px; + padding-right: 10px; + background-color: #FFEA20; + white-space: nowrap; + font-family: sans-serif; +} + +/* Directory view/File view (all): percentage entry for files with + low coverage rate */ +td.coverPerLo +{ + text-align: right; + padding-left: 10px; + padding-right: 10px; + background-color: #FF0000; + font-weight: bold; + font-family: sans-serif; +} + +/* Directory view/File view (all): line count entry for files with + low coverage rate */ +td.coverNumLo +{ + text-align: right; + padding-left: 10px; + padding-right: 10px; + background-color: #FF0000; + white-space: nowrap; + font-family: sans-serif; +} + +/* File view (all): "show/hide details" link format */ +a.detail:link +{ + color: #B8D0FF; + font-size:80%; +} + +/* File view (all): "show/hide details" link - visited format */ +a.detail:visited +{ + color: #B8D0FF; + font-size:80%; +} + +/* File view (all): "show/hide details" link - activated format */ +a.detail:active +{ + color: #FFFFFF; + font-size:80%; +} + +/* File view (detail): test name entry */ +td.testName +{ + text-align: right; + padding-right: 10px; + background-color: #DAE7FE; + font-family: sans-serif; +} + +/* File view (detail): test percentage entry */ +td.testPer +{ + text-align: right; + padding-left: 10px; + padding-right: 10px; + background-color: #DAE7FE; + font-family: sans-serif; +} + +/* File view (detail): test lines count entry */ +td.testNum +{ + text-align: right; + padding-left: 10px; + padding-right: 10px; + background-color: #DAE7FE; + font-family: sans-serif; +} + +/* Test case descriptions: test name format*/ +dt +{ + font-family: sans-serif; + font-weight: bold; +} + +/* Test case descriptions: description table body */ +td.testDescription +{ + padding-top: 10px; + padding-left: 30px; + padding-bottom: 10px; + padding-right: 30px; + background-color: #DAE7FE; +} + +/* Source code view: function entry */ +td.coverFn +{ + text-align: left; + padding-left: 10px; + padding-right: 20px; + color: #284FA8; + background-color: #DAE7FE; + font-family: monospace; +} + +/* Source code view: function entry zero count*/ +td.coverFnLo +{ + text-align: right; + padding-left: 10px; + padding-right: 10px; + background-color: #FF0000; + font-weight: bold; + font-family: sans-serif; +} + +/* Source code view: function entry nonzero count*/ +td.coverFnHi +{ + text-align: right; + padding-left: 10px; + padding-right: 10px; + background-color: #DAE7FE; + font-weight: bold; + font-family: sans-serif; +} + +/* Source code view: source code format */ +pre.source +{ + font-family: monospace; + white-space: pre; + margin-top: 2px; +} + +/* Source code view: line number format */ +span.lineNum +{ + background-color: #EFE383; +} + +/* Source code view: format for lines which were executed */ +td.lineCov, +span.lineCov +{ + background-color: #CAD7FE; +} + +/* Source code view: format for Cov legend */ +span.coverLegendCov +{ + padding-left: 10px; + padding-right: 10px; + padding-bottom: 2px; + background-color: #CAD7FE; +} + +/* Source code view: format for lines which were not executed */ +td.lineNoCov, +span.lineNoCov +{ + background-color: #FF6230; +} + +/* Source code view: format for NoCov legend */ +span.coverLegendNoCov +{ + padding-left: 10px; + padding-right: 10px; + padding-bottom: 2px; + background-color: #FF6230; +} + +/* Source code view (function table): standard link - visited format */ +td.lineNoCov > a:visited, +td.lineCov > a:visited +{ + color: black; + text-decoration: underline; +} + +/* Source code view: format for lines which were executed only in a + previous version */ +span.lineDiffCov +{ + background-color: #B5F7AF; +} + +/* Source code view: format for branches which were executed + * and taken */ +span.branchCov +{ + background-color: #CAD7FE; +} + +/* Source code view: format for branches which were executed + * but not taken */ +span.branchNoCov +{ + background-color: #FF6230; +} + +/* Source code view: format for branches which were not executed */ +span.branchNoExec +{ + background-color: #FF6230; +} + +/* Source code view: format for the source code heading line */ +pre.sourceHeading +{ + white-space: pre; + font-family: monospace; + font-weight: bold; + margin: 0px; +} + +/* All views: header legend value for low rate */ +td.headerValueLegL +{ + font-family: sans-serif; + text-align: center; + white-space: nowrap; + padding-left: 4px; + padding-right: 2px; + background-color: #FF0000; + font-size: 80%; +} + +/* All views: header legend value for med rate */ +td.headerValueLegM +{ + font-family: sans-serif; + text-align: center; + white-space: nowrap; + padding-left: 2px; + padding-right: 2px; + background-color: #FFEA20; + font-size: 80%; +} + +/* All views: header legend value for hi rate */ +td.headerValueLegH +{ + font-family: sans-serif; + text-align: center; + white-space: nowrap; + padding-left: 2px; + padding-right: 4px; + background-color: #A7FC9D; + font-size: 80%; +} + +/* All views except source code view: legend format for low coverage */ +span.coverLegendCovLo +{ + padding-left: 10px; + padding-right: 10px; + padding-top: 2px; + background-color: #FF0000; +} + +/* All views except source code view: legend format for med coverage */ +span.coverLegendCovMed +{ + padding-left: 10px; + padding-right: 10px; + padding-top: 2px; + background-color: #FFEA20; +} + +/* All views except source code view: legend format for hi coverage */ +span.coverLegendCovHi +{ + padding-left: 10px; + padding-right: 10px; + padding-top: 2px; + background-color: #A7FC9D; +} diff --git a/glass.png b/glass.png new file mode 100644 index 0000000000000000000000000000000000000000..e1abc00680a3093c49fdb775ae6bdb6764c95af2 GIT binary patch literal 167 zcmeAS@N?(olHy`uVBq!ia0vp^j3CU&3?x-=hn)gaEa{HEjtmSN`?>!lvI6;R0X`wF z|Ns97GD8ntt^-nxB|(0{3=Yq3q=7g|-tI089jvk*Kn`btM`SSr1Gf+eGhVt|_XjA* zUgGKN%6^Gmn4d%Ph(nkFP>9RZ#WAE}PI3Z}&BVayv3^M*kj3EX>gTe~DWM4f=_Dpv literal 0 HcmV?d00001 diff --git a/index-sort-f.html b/index-sort-f.html new file mode 100644 index 0000000000..0fadb8be28 --- /dev/null +++ b/index-sort-f.html @@ -0,0 +1,143 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top levelHitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1074110741100.0 %
Date:2024-08-29 20:08:04Functions:397397100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Directory Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
src/algorithm +
100.0%
+
100.0 %805 / 805100.0 %16 / 16
experimental/utility +
100.0%
+
100.0 %343 / 343100.0 %17 / 17
experimental/test +
100.0%
+
100.0 %1702 / 1702100.0 %42 / 42
experimental/algorithm +
100.0%
+
100.0 %2057 / 2057100.0 %60 / 60
src/utility +
100.0%
+
100.0 %1725 / 1725100.0 %100 / 100
src/test +
100.0%
+
100.0 %4109 / 4109100.0 %162 / 162
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/index-sort-l.html b/index-sort-l.html new file mode 100644 index 0000000000..b0b1da0a76 --- /dev/null +++ b/index-sort-l.html @@ -0,0 +1,143 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top levelHitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1074110741100.0 %
Date:2024-08-29 20:08:04Functions:397397100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Directory Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
experimental/utility +
100.0%
+
100.0 %343 / 343100.0 %17 / 17
src/algorithm +
100.0%
+
100.0 %805 / 805100.0 %16 / 16
experimental/test +
100.0%
+
100.0 %1702 / 1702100.0 %42 / 42
src/utility +
100.0%
+
100.0 %1725 / 1725100.0 %100 / 100
experimental/algorithm +
100.0%
+
100.0 %2057 / 2057100.0 %60 / 60
src/test +
100.0%
+
100.0 %4109 / 4109100.0 %162 / 162
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/index.html b/index.html new file mode 100644 index 0000000000..eae3217f88 --- /dev/null +++ b/index.html @@ -0,0 +1,143 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top levelHitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1074110741100.0 %
Date:2024-08-29 20:08:04Functions:397397100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Directory Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
experimental/algorithm +
100.0%
+
100.0 %2057 / 2057100.0 %60 / 60
experimental/test +
100.0%
+
100.0 %1702 / 1702100.0 %42 / 42
experimental/utility +
100.0%
+
100.0 %343 / 343100.0 %17 / 17
src/algorithm +
100.0%
+
100.0 %805 / 805100.0 %16 / 16
src/test +
100.0%
+
100.0 %4109 / 4109100.0 %162 / 162
src/utility +
100.0%
+
100.0 %1725 / 1725100.0 %100 / 100
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/ruby.png b/ruby.png new file mode 100644 index 0000000000000000000000000000000000000000..991b6d4ec9e78be165e3ef757eed1aada287364d GIT binary patch literal 141 zcmeAS@N?(olHy`uVBq!ia0vp^j3CU&3?x-=hn)ga>?NMQuI!iC1^FceV#7`HfI^%F z9+AZi4BSE>%y{W;-5;PJOS+@4BLl<6e(pbstUx|nfKQ0)e^Y%R^MdiLxj>4`)5S5Q b;#P73kj=!v_*DHKNFRfztDnm{r-UW|iOwIS literal 0 HcmV?d00001 diff --git a/snow.png b/snow.png new file mode 100644 index 0000000000000000000000000000000000000000..2cdae107fceec6e7f02ac7acb4a34a82a540caa5 GIT binary patch literal 141 zcmeAS@N?(olHy`uVBq!ia0vp^j3CU&3?x-=hn)ga>?NMQuI!iC1^MM!lvI6;R0X`wF|Ns97GD8ntt^-nBo-U3d c6}OTTfNUlP#;5A{K>8RwUHx3vIVCg!071?oo&W#< literal 0 HcmV?d00001 diff --git a/src/algorithm/LAGr_Betweenness.c.func-sort-c.html b/src/algorithm/LAGr_Betweenness.c.func-sort-c.html new file mode 100644 index 0000000000..144346801f --- /dev/null +++ b/src/algorithm/LAGr_Betweenness.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/algorithm/LAGr_Betweenness.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/algorithm - LAGr_Betweenness.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:7070100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGr_Betweenness143
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/algorithm/LAGr_Betweenness.c.func.html b/src/algorithm/LAGr_Betweenness.c.func.html new file mode 100644 index 0000000000..5752199315 --- /dev/null +++ b/src/algorithm/LAGr_Betweenness.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/algorithm/LAGr_Betweenness.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/algorithm - LAGr_Betweenness.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:7070100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGr_Betweenness143
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/algorithm/LAGr_Betweenness.c.gcov.html b/src/algorithm/LAGr_Betweenness.c.gcov.html new file mode 100644 index 0000000000..8b63fc336a --- /dev/null +++ b/src/algorithm/LAGr_Betweenness.c.gcov.html @@ -0,0 +1,396 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/algorithm/LAGr_Betweenness.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/algorithm - LAGr_Betweenness.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:7070100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGr_Betweenness: vertex betweenness-centrality
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Scott Kolodziej and Tim Davis, Texas A&M University;
+      15             : // Adapted and revised from GraphBLAS C API Spec, Appendix B.4.
+      16             : 
+      17             : //------------------------------------------------------------------------------
+      18             : 
+      19             : // LAGr_Betweenness: Batch algorithm for computing
+      20             : // betweeness centrality, using push-pull optimization.
+      21             : 
+      22             : // This is an Advanced algorithm (G->AT is required).
+      23             : 
+      24             : // This method computes an approximation of the betweenness algorithm.
+      25             : //                               ____
+      26             : //                               \      sigma(s,t | i)
+      27             : //    Betweenness centrality =    \    ----------------
+      28             : //           of node i            /       sigma(s,t)
+      29             : //                               /___
+      30             : //                            s != i != t
+      31             : //
+      32             : // Where sigma(s,t) is the total number of shortest paths from node s to
+      33             : // node t, and sigma(s,t | i) is the total number of shortest paths from
+      34             : // node s to node t that pass through node i.
+      35             : //
+      36             : // Note that the true betweenness centrality requires computing shortest paths
+      37             : // from all nodes s to all nodes t (or all-pairs shortest paths), which can be
+      38             : // expensive to compute. By using a reasonably sized subset of source nodes, an
+      39             : // approximation can be made.
+      40             : //
+      41             : // This method performs simultaneous breadth-first searches of the entire graph
+      42             : // starting at a given set of source nodes. This pass discovers all shortest
+      43             : // paths from the source nodes to all other nodes in the graph.  After the BFS
+      44             : // is complete, the number of shortest paths that pass through a given node is
+      45             : // tallied by reversing the traversal. From this, the (approximate) betweenness
+      46             : // centrality is computed.
+      47             : 
+      48             : // G->A represents the graph, and G->AT must be present.  G->A must be square,
+      49             : // and can be unsymmetric.  Self-edges are OK.  The values of G->A and G->AT
+      50             : // are ignored; just the structure of two matrices are used.
+      51             : 
+      52             : // Each phase uses push-pull direction optimization.
+      53             : 
+      54             : //------------------------------------------------------------------------------
+      55             : 
+      56             : #define LG_FREE_WORK                            \
+      57             : {                                               \
+      58             :     GrB_free (&frontier) ;                      \
+      59             :     GrB_free (&paths) ;                         \
+      60             :     GrB_free (&bc_update) ;                     \
+      61             :     GrB_free (&W) ;                             \
+      62             :     if (S != NULL)                              \
+      63             :     {                                           \
+      64             :         for (int64_t i = 0 ; i < n ; i++)       \
+      65             :         {                                       \
+      66             :             if (S [i] == NULL) break ;          \
+      67             :             GrB_free (&(S [i])) ;               \
+      68             :         }                                       \
+      69             :         LAGraph_Free ((void **) &S, NULL) ;     \
+      70             :     }                                           \
+      71             : }
+      72             : 
+      73             : #define LG_FREE_ALL                 \
+      74             : {                                   \
+      75             :     LG_FREE_WORK ;                  \
+      76             :     GrB_free (centrality) ;         \
+      77             : }
+      78             : 
+      79             : #include "LG_internal.h"
+      80             : 
+      81             : //------------------------------------------------------------------------------
+      82             : // LAGr_Betweenness: vertex betweenness-centrality
+      83             : //------------------------------------------------------------------------------
+      84             : 
+      85         143 : int LAGr_Betweenness
+      86             : (
+      87             :     // output:
+      88             :     GrB_Vector *centrality,     // centrality(i): betweeness centrality of i
+      89             :     // input:
+      90             :     LAGraph_Graph G,            // input graph
+      91             :     const GrB_Index *sources,   // source vertices to compute shortest paths
+      92             :     int32_t ns,                 // number of source vertices
+      93             :     char *msg
+      94             : )
+      95             : {
+      96             : 
+      97             :     //--------------------------------------------------------------------------
+      98             :     // check inputs
+      99             :     //--------------------------------------------------------------------------
+     100             : 
+     101         143 :     LG_CLEAR_MSG ;
+     102             : 
+     103             :     // Array of BFS search matrices.
+     104             :     // S [i] is a sparse matrix that stores the depth at which each vertex is
+     105             :     // first seen thus far in each BFS at the current depth i. Each column
+     106             :     // corresponds to a BFS traversal starting from a source node.
+     107         143 :     GrB_Matrix *S = NULL ;
+     108             : 
+     109             :     // Frontier matrix, a sparse matrix.
+     110             :     // Stores # of shortest paths to vertices at current BFS depth
+     111         143 :     GrB_Matrix frontier = NULL ;
+     112             : 
+     113             :     // Paths matrix holds the number of shortest paths for each node and
+     114             :     // starting node discovered so far.  A dense matrix that is updated with
+     115             :     // sparse updates, and also used as a mask.
+     116         143 :     GrB_Matrix paths = NULL ;
+     117             : 
+     118             :     // Update matrix for betweenness centrality, values for each node for
+     119             :     // each starting node.  A dense matrix.
+     120         143 :     GrB_Matrix bc_update = NULL ;
+     121             : 
+     122             :     // Temporary workspace matrix (sparse).
+     123         143 :     GrB_Matrix W = NULL ;
+     124             : 
+     125         143 :     GrB_Index n = 0 ;                   // # nodes in the graph
+     126             : 
+     127         143 :     LG_ASSERT (centrality != NULL && sources != NULL, GrB_NULL_POINTER) ;
+     128         143 :     (*centrality) = NULL ;
+     129         143 :     LG_TRY (LAGraph_CheckGraph (G, msg)) ;
+     130             : 
+     131         143 :     GrB_Matrix A = G->A ;
+     132             :     GrB_Matrix AT ;
+     133         143 :     if (G->kind == LAGraph_ADJACENCY_UNDIRECTED ||
+     134           1 :         G->is_symmetric_structure == LAGraph_TRUE)
+     135             :     {
+     136             :         // A and A' have the same structure
+     137         142 :         AT = A ;
+     138             :     }
+     139             :     else
+     140             :     {
+     141             :         // A and A' differ
+     142           1 :         AT = G->AT ;
+     143           1 :         LG_ASSERT_MSG (AT != NULL, LAGRAPH_NOT_CACHED, "G->AT is required") ;
+     144             :     }
+     145             : 
+     146             :     // =========================================================================
+     147             :     // === initializations =====================================================
+     148             :     // =========================================================================
+     149             : 
+     150             :     // Initialize paths and frontier with source notes
+     151         143 :     GRB_TRY (GrB_Matrix_nrows (&n, A)) ;
+     152         143 :     GRB_TRY (GrB_Matrix_new (&paths,    GrB_FP64, ns, n)) ;
+     153         140 :     GRB_TRY (GrB_Matrix_new (&frontier, GrB_FP64, ns, n)) ;
+     154             :     #if LAGRAPH_SUITESPARSE
+     155         137 :     GRB_TRY (GxB_set (paths, GxB_SPARSITY_CONTROL, GxB_BITMAP + GxB_FULL)) ;
+     156             :     #endif
+     157         655 :     for (GrB_Index i = 0 ; i < ns ; i++)
+     158             :     {
+     159             :         // paths (i,s(i)) = 1
+     160             :         // frontier (i,s(i)) = 1
+     161         525 :         double one = 1 ;
+     162         525 :         GrB_Index src = sources [i] ;
+     163         525 :         LG_ASSERT_MSG (src < n, GrB_INVALID_INDEX, "invalid source node") ;
+     164         525 :         GRB_TRY (GrB_Matrix_setElement (paths,    one, i, src)) ;
+     165         524 :         GRB_TRY (GrB_Matrix_setElement (frontier, one, i, src)) ;
+     166             :     }
+     167             : 
+     168             :     // Initial frontier: frontier<!paths>= frontier*A
+     169         130 :     GRB_TRY (GrB_mxm (frontier, paths, NULL, LAGraph_plus_first_fp64,
+     170             :         frontier, A, GrB_DESC_RSC)) ;
+     171             : 
+     172             :     // Allocate memory for the array of S matrices
+     173         117 :     LG_TRY (LAGraph_Malloc ((void **) &S, n+1, sizeof (GrB_Matrix), msg)) ;
+     174         116 :     S [0] = NULL ;
+     175             : 
+     176             :     // =========================================================================
+     177             :     // === Breadth-first search stage ==========================================
+     178             :     // =========================================================================
+     179             : 
+     180         116 :     bool last_was_pull = false ;
+     181         116 :     GrB_Index frontier_size, last_frontier_size = 0 ;
+     182         116 :     GRB_TRY (GrB_Matrix_nvals (&frontier_size, frontier)) ;
+     183             : 
+     184             :     int64_t depth ;
+     185         567 :     for (depth = 0 ; frontier_size > 0 && depth < n ; depth++)
+     186             :     {
+     187             : 
+     188             :         //----------------------------------------------------------------------
+     189             :         // S [depth] = structure of frontier
+     190             :         //----------------------------------------------------------------------
+     191             : 
+     192         496 :         S [depth+1] = NULL ;
+     193         556 :         LG_TRY (LAGraph_Matrix_Structure (&(S [depth]), frontier, msg)) ;
+     194             : 
+     195             :         //----------------------------------------------------------------------
+     196             :         // Accumulate path counts: paths += frontier
+     197             :         //----------------------------------------------------------------------
+     198             : 
+     199         467 :         GRB_TRY (GrB_assign (paths, NULL, GrB_PLUS_FP64, frontier, GrB_ALL, ns,
+     200             :             GrB_ALL, n, NULL)) ;
+     201             : 
+     202             :         //----------------------------------------------------------------------
+     203             :         // Update frontier: frontier<!paths> = frontier*A
+     204             :         //----------------------------------------------------------------------
+     205             : 
+     206             :         // pull if frontier is more than 10% dense,
+     207             :         // or > 6% dense and last step was pull
+     208         465 :         double frontier_density = ((double) frontier_size) / (double) (ns*n) ;
+     209         465 :         bool do_pull = frontier_density > (last_was_pull ? 0.06 : 0.10 ) ;
+     210             : 
+     211         465 :         if (do_pull)
+     212             :         {
+     213             :             // frontier<!paths> = frontier*AT'
+     214             :             #if LAGRAPH_SUITESPARSE
+     215         387 :             GRB_TRY (GxB_set (frontier, GxB_SPARSITY_CONTROL, GxB_BITMAP)) ;
+     216             :             #endif
+     217         407 :             GRB_TRY (GrB_mxm (frontier, paths, NULL, LAGraph_plus_first_fp64,
+     218             :                 frontier, AT, GrB_DESC_RSCT1)) ;
+     219             :         }
+     220             :         else // push
+     221             :         {
+     222             :             // frontier<!paths> = frontier*A
+     223             :             #if LAGRAPH_SUITESPARSE
+     224          93 :             GRB_TRY (GxB_set (frontier, GxB_SPARSITY_CONTROL, GxB_SPARSE)) ;
+     225             :             #endif
+     226          90 :             GRB_TRY (GrB_mxm (frontier, paths, NULL, LAGraph_plus_first_fp64,
+     227             :                 frontier, A, GrB_DESC_RSC)) ;
+     228             :         }
+     229             : 
+     230             :         //----------------------------------------------------------------------
+     231             :         // Get size of current frontier: frontier_size = nvals(frontier)
+     232             :         //----------------------------------------------------------------------
+     233             : 
+     234         451 :         last_frontier_size = frontier_size ;
+     235         451 :         last_was_pull = do_pull ;
+     236         451 :         GRB_TRY (GrB_Matrix_nvals (&frontier_size, frontier)) ;
+     237             :     }
+     238             : 
+     239          71 :     GRB_TRY (GrB_free (&frontier)) ;
+     240             : 
+     241             :     // =========================================================================
+     242             :     // === Betweenness centrality computation phase ============================
+     243             :     // =========================================================================
+     244             : 
+     245             :     // bc_update = ones (ns, n) ; a full matrix (and stays full)
+     246          86 :     GRB_TRY (GrB_Matrix_new (&bc_update, GrB_FP64, ns, n)) ;
+     247          73 :     GRB_TRY (GrB_assign (bc_update, NULL, NULL, 1, GrB_ALL, ns, GrB_ALL, n,
+     248             :         NULL)) ;
+     249             :     // W: empty ns-by-n array, as workspace
+     250          82 :     GRB_TRY (GrB_Matrix_new (&W, GrB_FP64, ns, n)) ;
+     251             : 
+     252             :     // Backtrack through the BFS and compute centrality updates for each vertex
+     253         175 :     for (int64_t i = depth-1 ; i > 0 ; i--)
+     254             :     {
+     255             : 
+     256             :         //----------------------------------------------------------------------
+     257             :         // W<S[i]> = bc_update ./ paths
+     258             :         //----------------------------------------------------------------------
+     259             : 
+     260             :         // Add contributions by successors and mask with that level's frontier
+     261         301 :         GRB_TRY (GrB_eWiseMult (W, S [i], NULL, GrB_DIV_FP64, bc_update, paths,
+     262             :             GrB_DESC_RS)) ;
+     263             : 
+     264             :         //----------------------------------------------------------------------
+     265             :         // W<S[i−1]> = W * A'
+     266             :         //----------------------------------------------------------------------
+     267             : 
+     268             :         // pull if W is more than 10% dense and nnz(W)/nnz(S[i-1]) > 1
+     269             :         // or if W is more than 1% dense and nnz(W)/nnz(S[i-1]) > 10
+     270             :         GrB_Index wsize, ssize ;
+     271         146 :         GrB_Matrix_nvals (&wsize, W) ;
+     272         146 :         GrB_Matrix_nvals (&ssize, S [i-1]) ;
+     273         146 :         double w_density    = ((double) wsize) / ((double) (ns*n)) ;
+     274         146 :         double w_to_s_ratio = ((double) wsize) / ((double) ssize) ;
+     275         218 :         bool do_pull = (w_density > 0.1  && w_to_s_ratio > 1.) ||
+     276          72 :                        (w_density > 0.01 && w_to_s_ratio > 10.) ;
+     277             : 
+     278         146 :         if (do_pull)
+     279             :         {
+     280             :             // W<S[i−1]> = W * A'
+     281             :             #if LAGRAPH_SUITESPARSE
+     282          26 :             GRB_TRY (GxB_set (W, GxB_SPARSITY_CONTROL, GxB_BITMAP)) ;
+     283             :             #endif
+     284          24 :             GRB_TRY (GrB_mxm (W, S [i-1], NULL, LAGraph_plus_first_fp64, W, A,
+     285             :                 GrB_DESC_RST1)) ;
+     286             :         }
+     287             :         else // push
+     288             :         {
+     289             :             // W<S[i−1]> = W * AT
+     290             :             #if LAGRAPH_SUITESPARSE
+     291         130 :             GRB_TRY (GxB_set (W, GxB_SPARSITY_CONTROL, GxB_SPARSE)) ;
+     292             :             #endif
+     293         225 :             GRB_TRY (GrB_mxm (W, S [i-1], NULL, LAGraph_plus_first_fp64, W, AT,
+     294             :                 GrB_DESC_RS)) ;
+     295             :         }
+     296             : 
+     297             :         //----------------------------------------------------------------------
+     298             :         // bc_update += W .* paths
+     299             :         //----------------------------------------------------------------------
+     300             : 
+     301         183 :         GRB_TRY (GrB_eWiseMult (bc_update, NULL, GrB_PLUS_FP64, GrB_TIMES_FP64,
+     302             :             W, paths, NULL)) ;
+     303             :     }
+     304             : 
+     305             :     // =========================================================================
+     306             :     // === finalize the centrality =============================================
+     307             :     // =========================================================================
+     308             : 
+     309             :     // Initialize the centrality array with -ns to avoid counting
+     310             :     // zero length paths
+     311          19 :     GRB_TRY (GrB_Vector_new (centrality, GrB_FP64, n)) ;
+     312          12 :     GRB_TRY (GrB_assign (*centrality, NULL, NULL, -ns, GrB_ALL, n, NULL)) ;
+     313             : 
+     314             :     // centrality (i) += sum (bc_update (:,i)) for all nodes i
+     315          21 :     GRB_TRY (GrB_reduce (*centrality, NULL, GrB_PLUS_FP64, GrB_PLUS_MONOID_FP64,
+     316             :         bc_update, GrB_DESC_T0)) ;
+     317             : 
+     318          18 :     LG_FREE_WORK ;
+     319           3 :     return (GrB_SUCCESS) ;
+     320             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/algorithm/LAGr_BreadthFirstSearch.c.func-sort-c.html b/src/algorithm/LAGr_BreadthFirstSearch.c.func-sort-c.html new file mode 100644 index 0000000000..9724306887 --- /dev/null +++ b/src/algorithm/LAGr_BreadthFirstSearch.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/algorithm/LAGr_BreadthFirstSearch.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/algorithm - LAGr_BreadthFirstSearch.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:22100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGr_BreadthFirstSearch9462
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/algorithm/LAGr_BreadthFirstSearch.c.func.html b/src/algorithm/LAGr_BreadthFirstSearch.c.func.html new file mode 100644 index 0000000000..f5e8cb6186 --- /dev/null +++ b/src/algorithm/LAGr_BreadthFirstSearch.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/algorithm/LAGr_BreadthFirstSearch.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/algorithm - LAGr_BreadthFirstSearch.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:22100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGr_BreadthFirstSearch9462
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/algorithm/LAGr_BreadthFirstSearch.c.gcov.html b/src/algorithm/LAGr_BreadthFirstSearch.c.gcov.html new file mode 100644 index 0000000000..244df44477 --- /dev/null +++ b/src/algorithm/LAGr_BreadthFirstSearch.c.gcov.html @@ -0,0 +1,121 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/algorithm/LAGr_BreadthFirstSearch.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/algorithm - LAGr_BreadthFirstSearch.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:22100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGr_BreadthFirstSearch:  breadth-first search dispatch
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Scott McMillan, SEI Carnegie Mellon University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // Breadth-first-search via push/pull method if using SuiteSparse:GraphBLAS
+      19             : // and its GxB extensions, or a push-only method otherwise.  The former is
+      20             : // much faster.
+      21             : 
+      22             : // This is an Advanced algorithm.  SuiteSparse can use a push/pull method if
+      23             : // G->AT and G->out_degree are provided.  G->AT is not required if G is
+      24             : // undirected.  The vanilla method is always push-only.
+      25             : 
+      26             : #include "LG_alg_internal.h"
+      27             : 
+      28        9462 : int LAGr_BreadthFirstSearch
+      29             : (
+      30             :     // output:
+      31             :     GrB_Vector *level,
+      32             :     GrB_Vector *parent,
+      33             :     // input:
+      34             :     const LAGraph_Graph G,
+      35             :     GrB_Index src,
+      36             :     char *msg
+      37             : )
+      38             : {
+      39             : 
+      40             : #if LAGRAPH_SUITESPARSE
+      41        9462 :     return LG_BreadthFirstSearch_SSGrB   (level, parent, G, src, msg) ;
+      42             : #else
+      43             :     return LG_BreadthFirstSearch_vanilla (level, parent, G, src, msg) ;
+      44             : #endif
+      45             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/algorithm/LAGr_ConnectedComponents.c.func-sort-c.html b/src/algorithm/LAGr_ConnectedComponents.c.func-sort-c.html new file mode 100644 index 0000000000..5649b10e6c --- /dev/null +++ b/src/algorithm/LAGr_ConnectedComponents.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/algorithm/LAGr_ConnectedComponents.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/algorithm - LAGr_ConnectedComponents.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:22100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGr_ConnectedComponents62
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/algorithm/LAGr_ConnectedComponents.c.func.html b/src/algorithm/LAGr_ConnectedComponents.c.func.html new file mode 100644 index 0000000000..5f2672a7f6 --- /dev/null +++ b/src/algorithm/LAGr_ConnectedComponents.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/algorithm/LAGr_ConnectedComponents.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/algorithm - LAGr_ConnectedComponents.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:22100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGr_ConnectedComponents62
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/algorithm/LAGr_ConnectedComponents.c.gcov.html b/src/algorithm/LAGr_ConnectedComponents.c.gcov.html new file mode 100644 index 0000000000..7a95a28e43 --- /dev/null +++ b/src/algorithm/LAGr_ConnectedComponents.c.gcov.html @@ -0,0 +1,117 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/algorithm/LAGr_ConnectedComponents.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/algorithm - LAGr_ConnectedComponents.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:22100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGr_ConnectedComponents:  connected components of an undirected graph
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // This is an Advanced algorithm (G->is_symmetric_structure must be known).
+      19             : 
+      20             : // Connected Components via LG_CC_FastSV6 if using SuiteSparse:GraphBLAS and
+      21             : // its GxB extensions, or LG_CC_Boruvka otherwise.  The former is much faster.
+      22             : 
+      23             : #include "LG_alg_internal.h"
+      24             : 
+      25          62 : int LAGr_ConnectedComponents
+      26             : (
+      27             :     // output:
+      28             :     GrB_Vector *component,  // component(i)=s if node i is in the component
+      29             :                             // whose representative node is s
+      30             :     // input:
+      31             :     const LAGraph_Graph G,  // input graph
+      32             :     char *msg
+      33             : )
+      34             : {
+      35             : 
+      36             :     #if LAGRAPH_SUITESPARSE
+      37          62 :     return (LG_CC_FastSV6 (component, G, msg)) ;
+      38             :     #else
+      39             :     return (LG_CC_Boruvka (component, G, msg)) ;
+      40             :     #endif
+      41             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/algorithm/LAGr_PageRank.c.func-sort-c.html b/src/algorithm/LAGr_PageRank.c.func-sort-c.html new file mode 100644 index 0000000000..3920146533 --- /dev/null +++ b/src/algorithm/LAGr_PageRank.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/algorithm/LAGr_PageRank.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/algorithm - LAGr_PageRank.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:5454100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGr_PageRank4
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/algorithm/LAGr_PageRank.c.func.html b/src/algorithm/LAGr_PageRank.c.func.html new file mode 100644 index 0000000000..d5c79c6c24 --- /dev/null +++ b/src/algorithm/LAGr_PageRank.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/algorithm/LAGr_PageRank.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/algorithm - LAGr_PageRank.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:5454100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGr_PageRank4
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/algorithm/LAGr_PageRank.c.gcov.html b/src/algorithm/LAGr_PageRank.c.gcov.html new file mode 100644 index 0000000000..629db097c5 --- /dev/null +++ b/src/algorithm/LAGr_PageRank.c.gcov.html @@ -0,0 +1,261 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/algorithm/LAGr_PageRank.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/algorithm - LAGr_PageRank.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:5454100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGr_PageRank: pagerank (for use in production, not for the GAP benchmark)
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis and Mohsen Aznaveh, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // This is an Advanced algorithm (G->AT and G->out_degree are required).
+      19             : 
+      20             : // PageRank (not for the GAP benchmark, but for production use).  Do not use
+      21             : // this method for the GAP benchmark.  Use LAGr_PageRankGAP instead.
+      22             : 
+      23             : // Unlike LAGr_PageRankGAP, this algorithm handles sinks correctly (nodes with
+      24             : // no outgoing edges).  The method in the GAP specification ignores sinks, and
+      25             : // thus sum(centrality) is not maintained as 1.  This method handles sinks
+      26             : // properly, and thus keeps sum(centrality) equal to 1.
+      27             : 
+      28             : // The G->AT and G->out_degree cached properties must be defined for this
+      29             : // method.  If G is undirected or G->A is known to have a symmetric structure,
+      30             : // then G->A is used instead of G->AT, however.  G->out_degree must be computed
+      31             : // so that it contains no explicit zeros; as done by LAGraph_Cached_OutDegree.
+      32             : 
+      33             : #define LG_FREE_WORK                \
+      34             : {                                   \
+      35             :     GrB_free (&d1) ;                \
+      36             :     GrB_free (&d) ;                 \
+      37             :     GrB_free (&t) ;                 \
+      38             :     GrB_free (&w) ;                 \
+      39             :     GrB_free (&sink) ;              \
+      40             :     GrB_free (&rsink) ;             \
+      41             : }
+      42             : 
+      43             : #define LG_FREE_ALL                 \
+      44             : {                                   \
+      45             :     LG_FREE_WORK ;                  \
+      46             :     GrB_free (&r) ;                 \
+      47             : }
+      48             : 
+      49             : #include "LG_internal.h"
+      50             : 
+      51           4 : int LAGr_PageRank
+      52             : (
+      53             :     // output:
+      54             :     GrB_Vector *centrality, // centrality(i): pagerank of node i
+      55             :     int *iters,             // number of iterations taken
+      56             :     // input:
+      57             :     const LAGraph_Graph G,  // input graph
+      58             :     float damping,          // damping factor (typically 0.85)
+      59             :     float tol,              // stopping tolerance (typically 1e-4) ;
+      60             :     int itermax,            // maximum number of iterations (typically 100)
+      61             :     char *msg
+      62             : )
+      63             : {
+      64             : 
+      65             :     //--------------------------------------------------------------------------
+      66             :     // check inputs
+      67             :     //--------------------------------------------------------------------------
+      68             : 
+      69           4 :     LG_CLEAR_MSG ;
+      70           4 :     GrB_Vector r = NULL, d = NULL, t = NULL, w = NULL, d1 = NULL ;
+      71           4 :     GrB_Vector sink = NULL, rsink = NULL ;
+      72           4 :     LG_ASSERT (centrality != NULL && iters != NULL, GrB_NULL_POINTER) ;
+      73           4 :     LG_TRY (LAGraph_CheckGraph (G, msg)) ;
+      74             :     GrB_Matrix AT ;
+      75           4 :     if (G->kind == LAGraph_ADJACENCY_UNDIRECTED ||
+      76           2 :         G->is_symmetric_structure == LAGraph_TRUE)
+      77             :     {
+      78             :         // A and A' have the same structure
+      79           2 :         AT = G->A ;
+      80             :     }
+      81             :     else
+      82             :     {
+      83             :         // A and A' differ
+      84           2 :         AT = G->AT ;
+      85           2 :         LG_ASSERT_MSG (AT != NULL, LAGRAPH_NOT_CACHED, "G->AT is required") ;
+      86             :     }
+      87           4 :     GrB_Vector d_out = G->out_degree ;
+      88           4 :     LG_ASSERT_MSG (d_out != NULL,
+      89             :         LAGRAPH_NOT_CACHED, "G->out_degree is required") ;
+      90             : 
+      91             :     //--------------------------------------------------------------------------
+      92             :     // initializations
+      93             :     //--------------------------------------------------------------------------
+      94             : 
+      95             :     GrB_Index n ;
+      96           4 :     (*centrality) = NULL ;
+      97           4 :     GRB_TRY (GrB_Matrix_nrows (&n, AT)) ;
+      98             : 
+      99           4 :     const float damping_over_n = damping / n ;
+     100           4 :     const float scaled_damping = (1 - damping) / n ;
+     101           4 :     float rdiff = 1 ;       // first iteration is always done
+     102             : 
+     103             :     // r = 1 / n
+     104           4 :     GRB_TRY (GrB_Vector_new (&t, GrB_FP32, n)) ;
+     105           4 :     GRB_TRY (GrB_Vector_new (&r, GrB_FP32, n)) ;
+     106           4 :     GRB_TRY (GrB_Vector_new (&w, GrB_FP32, n)) ;
+     107           4 :     GRB_TRY (GrB_assign (r, NULL, NULL, (float) (1.0 / n), GrB_ALL, n, NULL)) ;
+     108             : 
+     109             :     // find all sinks, where sink(i) = true if node i has d_out(i)=0, or with
+     110             :     // d_out(i) not present.  LAGraph_Cached_OutDegree computes d_out =
+     111             :     // G->out_degree so that it has no explicit zeros, so a structural mask can
+     112             :     // be used here.
+     113             :     GrB_Index nsinks, nvals ;
+     114           4 :     GRB_TRY (GrB_Vector_nvals (&nvals, d_out)) ;
+     115           4 :     nsinks = n - nvals ;
+     116           4 :     if (nsinks > 0)
+     117             :     {
+     118             :         // sink<!struct(d_out)> = true
+     119           1 :         GRB_TRY (GrB_Vector_new (&sink, GrB_BOOL, n)) ;
+     120           1 :         GRB_TRY (GrB_assign (sink, d_out, NULL, (bool) true, GrB_ALL, n,
+     121             :             GrB_DESC_SC)) ;
+     122           1 :         GRB_TRY (GrB_Vector_new (&rsink, GrB_FP32, n)) ;
+     123             :     }
+     124             : 
+     125             :     // prescale with damping factor, so it isn't done each iteration
+     126             :     // d = d_out / damping ;
+     127           4 :     GRB_TRY (GrB_Vector_new (&d, GrB_FP32, n)) ;
+     128           4 :     GRB_TRY (GrB_apply (d, NULL, NULL, GrB_DIV_FP32, d_out, damping, NULL)) ;
+     129             : 
+     130             :     // d1 = 1 / damping
+     131           4 :     float dmin = 1.0 / damping ;
+     132           4 :     GRB_TRY (GrB_Vector_new (&d1, GrB_FP32, n)) ;
+     133           4 :     GRB_TRY (GrB_assign (d1, NULL, NULL, dmin, GrB_ALL, n, NULL)) ;
+     134             :     // d = max (d1, d)
+     135           4 :     GRB_TRY (GrB_eWiseAdd (d, NULL, NULL, GrB_MAX_FP32, d1, d, NULL)) ;
+     136           4 :     GrB_free (&d1) ;
+     137             : 
+     138             :     //--------------------------------------------------------------------------
+     139             :     // pagerank iterations
+     140             :     //--------------------------------------------------------------------------
+     141             : 
+     142          48 :     for ((*iters) = 0 ; rdiff > tol ; (*iters)++)
+     143             :     {
+     144             :         // check for convergence
+     145          45 :         LG_ASSERT_MSGF ((*iters) < itermax, LAGRAPH_CONVERGENCE_FAILURE,
+     146             :             "pagerank failed to converge in %d iterations", itermax) ;
+     147             :         // determine teleport and handle any sinks
+     148          44 :         float teleport = scaled_damping ; // teleport = (1 - damping) / n
+     149          44 :         if (nsinks > 0)
+     150             :         {
+     151             :             // handle the sinks: teleport += (damping/n) * sum (r (sink))
+     152             :             // rsink<struct(sink)> = r
+     153          12 :             GRB_TRY (GrB_Vector_clear (rsink)) ;
+     154          12 :             GRB_TRY (GrB_assign (rsink, sink, NULL, r, GrB_ALL, n, GrB_DESC_S));
+     155             :             // sum_rsink = sum (rsink)
+     156          12 :             float sum_rsink = 0 ;
+     157          12 :             GRB_TRY (GrB_reduce (&sum_rsink, NULL, GrB_PLUS_MONOID_FP32,
+     158             :                 rsink, NULL)) ;
+     159          12 :             teleport += damping_over_n * sum_rsink ;
+     160             :         }
+     161             :         // swap t and r ; now t is the old score
+     162          44 :         GrB_Vector temp = t ; t = r ; r = temp ;
+     163             :         // w = t ./ d
+     164          44 :         GRB_TRY (GrB_eWiseMult (w, NULL, NULL, GrB_DIV_FP32, t, d, NULL)) ;
+     165             :         // r = teleport
+     166          44 :         GRB_TRY (GrB_assign (r, NULL, NULL, teleport, GrB_ALL, n, NULL)) ;
+     167             :         // r += A'*w
+     168          44 :         GRB_TRY (GrB_mxv (r, NULL, GrB_PLUS_FP32, LAGraph_plus_second_fp32,
+     169             :             AT, w, NULL)) ;
+     170             :         // t -= r
+     171          44 :         GRB_TRY (GrB_assign (t, NULL, GrB_MINUS_FP32, r, GrB_ALL, n, NULL)) ;
+     172             :         // t = abs (t)
+     173          44 :         GRB_TRY (GrB_apply (t, NULL, NULL, GrB_ABS_FP32, t, NULL)) ;
+     174             :         // rdiff = sum (t)
+     175          44 :         GRB_TRY (GrB_reduce (&rdiff, NULL, GrB_PLUS_MONOID_FP32, t, NULL)) ;
+     176             :     }
+     177             : 
+     178             :     //--------------------------------------------------------------------------
+     179             :     // free workspace and return result
+     180             :     //--------------------------------------------------------------------------
+     181             : 
+     182           3 :     (*centrality) = r ;
+     183           3 :     LG_FREE_WORK ;
+     184           3 :     return (GrB_SUCCESS) ;
+     185             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/algorithm/LAGr_PageRankGAP.c.func-sort-c.html b/src/algorithm/LAGr_PageRankGAP.c.func-sort-c.html new file mode 100644 index 0000000000..e2bd1778bf --- /dev/null +++ b/src/algorithm/LAGr_PageRankGAP.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/algorithm/LAGr_PageRankGAP.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/algorithm - LAGr_PageRankGAP.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3939100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGr_PageRankGAP3
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/algorithm/LAGr_PageRankGAP.c.func.html b/src/algorithm/LAGr_PageRankGAP.c.func.html new file mode 100644 index 0000000000..f51994b7b5 --- /dev/null +++ b/src/algorithm/LAGr_PageRankGAP.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/algorithm/LAGr_PageRankGAP.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/algorithm - LAGr_PageRankGAP.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3939100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGr_PageRankGAP3
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/algorithm/LAGr_PageRankGAP.c.gcov.html b/src/algorithm/LAGr_PageRankGAP.c.gcov.html new file mode 100644 index 0000000000..cfdf935cf8 --- /dev/null +++ b/src/algorithm/LAGr_PageRankGAP.c.gcov.html @@ -0,0 +1,228 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/algorithm/LAGr_PageRankGAP.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/algorithm - LAGr_PageRankGAP.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3939100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGr_PageRankGAP: pagerank for the GAP benchmark
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis and Mohsen Aznaveh, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // This is an Advanced algorithm (G->AT and G->out_degree are required).
+      19             : 
+      20             : // PageRank for the GAP benchmark (only).  Do not use in production.
+      21             : 
+      22             : // This algorithm follows the specification given in the GAP Benchmark Suite:
+      23             : // https://arxiv.org/abs/1508.03619 which assumes that both A and A' are
+      24             : // already available, as are the row and column degrees.  The GAP specification
+      25             : // ignores dangling nodes (nodes with no outgoing edges, also called sinks),
+      26             : // and thus shouldn't be used in production.  This method is for the GAP
+      27             : // benchmark only.  See LAGr_PageRank for a method that
+      28             : // handles sinks correctly.  This method does not return a centrality metric
+      29             : // such that sum(centrality) is 1, if sinks are present.
+      30             : 
+      31             : // The G->AT and G->out_degree cached properties must be defined for this
+      32             : // method.  If G is undirected or G->A is known to have a symmetric structure,
+      33             : // then G->A is used instead of G->AT, however.
+      34             : 
+      35             : #define LG_FREE_WORK                \
+      36             : {                                   \
+      37             :     GrB_free (&d1) ;                \
+      38             :     GrB_free (&d) ;                 \
+      39             :     GrB_free (&t) ;                 \
+      40             :     GrB_free (&w) ;                 \
+      41             : }
+      42             : 
+      43             : #define LG_FREE_ALL                 \
+      44             : {                                   \
+      45             :     LG_FREE_WORK ;                  \
+      46             :     GrB_free (&r) ;                 \
+      47             : }
+      48             : 
+      49             : #include "LG_internal.h"
+      50             : 
+      51           3 : int LAGr_PageRankGAP
+      52             : (
+      53             :     // output:
+      54             :     GrB_Vector *centrality, // centrality(i): GAP-style pagerank of node i
+      55             :     int *iters,             // number of iterations taken
+      56             :     // input:
+      57             :     const LAGraph_Graph G,  // input graph
+      58             :     float damping,          // damping factor (typically 0.85)
+      59             :     float tol,              // stopping tolerance (typically 1e-4) ;
+      60             :     int itermax,            // maximum number of iterations (typically 100)
+      61             :     char *msg
+      62             : )
+      63             : {
+      64             : 
+      65             :     //--------------------------------------------------------------------------
+      66             :     // check inputs
+      67             :     //--------------------------------------------------------------------------
+      68             : 
+      69           3 :     LG_CLEAR_MSG ;
+      70           3 :     GrB_Vector r = NULL, d = NULL, t = NULL, w = NULL, d1 = NULL ;
+      71           3 :     LG_ASSERT (centrality != NULL, GrB_NULL_POINTER) ;
+      72           3 :     LG_TRY (LAGraph_CheckGraph (G, msg)) ;
+      73             :     GrB_Matrix AT ;
+      74           3 :     if (G->kind == LAGraph_ADJACENCY_UNDIRECTED ||
+      75           2 :         G->is_symmetric_structure == LAGraph_TRUE)
+      76             :     {
+      77             :         // A and A' have the same structure
+      78           1 :         AT = G->A ;
+      79             :     }
+      80             :     else
+      81             :     {
+      82             :         // A and A' differ
+      83           2 :         AT = G->AT ;
+      84           2 :         LG_ASSERT_MSG (AT != NULL,
+      85             :             LAGRAPH_NOT_CACHED, "G->AT is required") ;
+      86             :     }
+      87           3 :     GrB_Vector d_out = G->out_degree ;
+      88           3 :     LG_ASSERT_MSG (d_out != NULL,
+      89             :         LAGRAPH_NOT_CACHED, "G->out_degree is required") ;
+      90             : 
+      91             :     //--------------------------------------------------------------------------
+      92             :     // initializations
+      93             :     //--------------------------------------------------------------------------
+      94             : 
+      95             :     GrB_Index n ;
+      96           3 :     (*centrality) = NULL ;
+      97           3 :     GRB_TRY (GrB_Matrix_nrows (&n, AT)) ;
+      98             : 
+      99           3 :     const float scaled_damping = (1 - damping) / n ;
+     100           3 :     const float teleport = scaled_damping ; // teleport = (1 - damping) / n
+     101           3 :     float rdiff = 1 ;       // first iteration is always done
+     102             : 
+     103             :     // r = 1 / n
+     104           3 :     GRB_TRY (GrB_Vector_new (&t, GrB_FP32, n)) ;
+     105           3 :     GRB_TRY (GrB_Vector_new (&r, GrB_FP32, n)) ;
+     106           3 :     GRB_TRY (GrB_Vector_new (&w, GrB_FP32, n)) ;
+     107           3 :     GRB_TRY (GrB_assign (r, NULL, NULL, (float) (1.0 / n), GrB_ALL, n, NULL)) ;
+     108             : 
+     109             :     // prescale with damping factor, so it isn't done each iteration
+     110             :     // d = d_out / damping ;
+     111           3 :     GRB_TRY (GrB_Vector_new (&d, GrB_FP32, n)) ;
+     112           3 :     GRB_TRY (GrB_apply (d, NULL, NULL, GrB_DIV_FP32, d_out, damping, NULL)) ;
+     113             : 
+     114             :     // d1 = 1 / damping
+     115           3 :     float dmin = 1.0 / damping ;
+     116           3 :     GRB_TRY (GrB_Vector_new (&d1, GrB_FP32, n)) ;
+     117           3 :     GRB_TRY (GrB_assign (d1, NULL, NULL, dmin, GrB_ALL, n, NULL)) ;
+     118             :     // d = max (d1, d)
+     119           3 :     GRB_TRY (GrB_eWiseAdd (d, NULL, NULL, GrB_MAX_FP32, d1, d, NULL)) ;
+     120           3 :     GrB_free (&d1) ;
+     121             : 
+     122             :     //--------------------------------------------------------------------------
+     123             :     // pagerank iterations
+     124             :     //--------------------------------------------------------------------------
+     125             : 
+     126          55 :     for ((*iters) = 0 ; (*iters) < itermax && rdiff > tol ; (*iters)++)
+     127             :     {
+     128             :         // swap t and r ; now t is the old score
+     129          52 :         GrB_Vector temp = t ; t = r ; r = temp ;
+     130             :         // w = t ./ d
+     131          52 :         GRB_TRY (GrB_eWiseMult (w, NULL, NULL, GrB_DIV_FP32, t, d, NULL)) ;
+     132             :         // r = teleport
+     133          52 :         GRB_TRY (GrB_assign (r, NULL, NULL, teleport, GrB_ALL, n, NULL)) ;
+     134             :         // r += A'*w
+     135          52 :         GRB_TRY (GrB_mxv (r, NULL, GrB_PLUS_FP32, LAGraph_plus_second_fp32,
+     136             :             AT, w, NULL)) ;
+     137             :         // t -= r
+     138          52 :         GRB_TRY (GrB_assign (t, NULL, GrB_MINUS_FP32, r, GrB_ALL, n, NULL)) ;
+     139             :         // t = abs (t)
+     140          52 :         GRB_TRY (GrB_apply (t, NULL, NULL, GrB_ABS_FP32, t, NULL)) ;
+     141             :         // rdiff = sum (t)
+     142          52 :         GRB_TRY (GrB_reduce (&rdiff, NULL, GrB_PLUS_MONOID_FP32, t, NULL)) ;
+     143             :     }
+     144             : 
+     145             :     //--------------------------------------------------------------------------
+     146             :     // free workspace and return result
+     147             :     //--------------------------------------------------------------------------
+     148             : 
+     149           3 :     (*centrality) = r ;
+     150           3 :     LG_FREE_WORK ;
+     151           3 :     return (GrB_SUCCESS) ;
+     152             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/algorithm/LAGr_SingleSourceShortestPath.c.func-sort-c.html b/src/algorithm/LAGr_SingleSourceShortestPath.c.func-sort-c.html new file mode 100644 index 0000000000..81a1c2bb5b --- /dev/null +++ b/src/algorithm/LAGr_SingleSourceShortestPath.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/algorithm/LAGr_SingleSourceShortestPath.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/algorithm - LAGr_SingleSourceShortestPath.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:161161100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGr_SingleSourceShortestPath3955
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/algorithm/LAGr_SingleSourceShortestPath.c.func.html b/src/algorithm/LAGr_SingleSourceShortestPath.c.func.html new file mode 100644 index 0000000000..a1c91d6412 --- /dev/null +++ b/src/algorithm/LAGr_SingleSourceShortestPath.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/algorithm/LAGr_SingleSourceShortestPath.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/algorithm - LAGr_SingleSourceShortestPath.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:161161100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGr_SingleSourceShortestPath3955
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/algorithm/LAGr_SingleSourceShortestPath.c.gcov.html b/src/algorithm/LAGr_SingleSourceShortestPath.c.gcov.html new file mode 100644 index 0000000000..b2ac98976c --- /dev/null +++ b/src/algorithm/LAGr_SingleSourceShortestPath.c.gcov.html @@ -0,0 +1,498 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/algorithm/LAGr_SingleSourceShortestPath.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/algorithm - LAGr_SingleSourceShortestPath.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:161161100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGr_SingleSourceShortestPath: single-source shortest path
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Jinhao Chen, Scott Kolodziej and Tim Davis, Texas A&M
+      15             : // University.  Adapted from GraphBLAS Template Library (GBTL) by Scott
+      16             : // McMillan and Tze Meng Low.
+      17             : 
+      18             : //------------------------------------------------------------------------------
+      19             : 
+      20             : // This is an Advanced algorithm (G->emin is required).
+      21             : 
+      22             : // Single source shortest path with delta stepping.
+      23             : 
+      24             : // U. Sridhar, M. Blanco, R. Mayuranath, D. G. Spampinato, T. M. Low, and
+      25             : // S. McMillan, "Delta-Stepping SSSP: From Vertices and Edges to GraphBLAS
+      26             : // Implementations," in 2019 IEEE International Parallel and Distributed
+      27             : // Processing Symposium Workshops (IPDPSW), 2019, pp. 241–250.
+      28             : // https://ieeexplore.ieee.org/document/8778222/references
+      29             : // https://arxiv.org/abs/1911.06895
+      30             : 
+      31             : // LAGr_SingleSourceShortestPath computes the shortest path lengths from the
+      32             : // specified source vertex to all other vertices in the graph.
+      33             : 
+      34             : // The parent vector is not computed; see LAGraph_BF_* instead.
+      35             : 
+      36             : // NOTE: this method gets stuck in an infinite loop when there are negative-
+      37             : // weight cycles in the graph.
+      38             : 
+      39             : // FUTURE: a Basic algorithm that picks Delta automatically
+      40             : 
+      41             : #define LG_FREE_WORK        \
+      42             : {                           \
+      43             :     GrB_free (&AL) ;        \
+      44             :     GrB_free (&AH) ;        \
+      45             :     GrB_free (&lBound) ;    \
+      46             :     GrB_free (&uBound) ;    \
+      47             :     GrB_free (&tmasked) ;   \
+      48             :     GrB_free (&tReq) ;      \
+      49             :     GrB_free (&tless) ;     \
+      50             :     GrB_free (&s) ;         \
+      51             :     GrB_free (&reach) ;     \
+      52             :     GrB_free (&Empty) ;     \
+      53             : }
+      54             : 
+      55             : #define LG_FREE_ALL         \
+      56             : {                           \
+      57             :     LG_FREE_WORK ;          \
+      58             :     GrB_free (&t) ;         \
+      59             : }
+      60             : 
+      61             : #include "LG_internal.h"
+      62             : 
+      63             : #define setelement(s, k)                                                      \
+      64             : {                                                                             \
+      65             :     switch (tcode)                                                            \
+      66             :     {                                                                         \
+      67             :         default:                                                              \
+      68             :         case 0 : GrB_Scalar_setElement_INT32  (s, k * delta_int32 ) ; break ; \
+      69             :         case 1 : GrB_Scalar_setElement_INT64  (s, k * delta_int64 ) ; break ; \
+      70             :         case 2 : GrB_Scalar_setElement_UINT32 (s, k * delta_uint32) ; break ; \
+      71             :         case 3 : GrB_Scalar_setElement_UINT64 (s, k * delta_uint64) ; break ; \
+      72             :         case 4 : GrB_Scalar_setElement_FP32   (s, k * delta_fp32  ) ; break ; \
+      73             :         case 5 : GrB_Scalar_setElement_FP64   (s, k * delta_fp64  ) ; break ; \
+      74             :     }                                                                         \
+      75             : }
+      76             : 
+      77        3955 : int LAGr_SingleSourceShortestPath
+      78             : (
+      79             :     // output:
+      80             :     GrB_Vector *path_length,    // path_length (i) is the length of the shortest
+      81             :                                 // path from the source vertex to vertex i
+      82             :     // input:
+      83             :     const LAGraph_Graph G,      // input graph, not modified
+      84             :     GrB_Index source,           // source vertex
+      85             :     GrB_Scalar Delta,           // delta value for delta stepping
+      86             :     char *msg
+      87             : )
+      88             : {
+      89             : 
+      90             :     //--------------------------------------------------------------------------
+      91             :     // check inputs
+      92             :     //--------------------------------------------------------------------------
+      93             : 
+      94        3955 :     LG_CLEAR_MSG ;
+      95        3955 :     GrB_Scalar lBound = NULL ;  // the threshold for GrB_select
+      96        3955 :     GrB_Scalar uBound = NULL ;  // the threshold for GrB_select
+      97        3955 :     GrB_Matrix AL = NULL ;      // graph containing the light weight edges
+      98        3955 :     GrB_Matrix AH = NULL ;      // graph containing the heavy weight edges
+      99        3955 :     GrB_Vector t = NULL ;       // tentative shortest path length
+     100        3955 :     GrB_Vector tmasked = NULL ;
+     101        3955 :     GrB_Vector tReq = NULL ;
+     102        3955 :     GrB_Vector tless = NULL ;
+     103        3955 :     GrB_Vector s = NULL ;
+     104        3955 :     GrB_Vector reach = NULL ;
+     105        3955 :     GrB_Vector Empty = NULL ;
+     106             : 
+     107        3955 :     LG_TRY (LAGraph_CheckGraph (G, msg)) ;
+     108        3955 :     LG_ASSERT (path_length != NULL && Delta != NULL, GrB_NULL_POINTER) ;
+     109        3955 :     (*path_length) = NULL ;
+     110             : 
+     111             :     GrB_Index nvals ;
+     112        3955 :     LG_TRY (GrB_Scalar_nvals (&nvals, Delta)) ;
+     113        3955 :     LG_ASSERT_MSG (nvals == 1, GrB_EMPTY_OBJECT, "Delta is missing") ;
+     114             : 
+     115        3954 :     GrB_Matrix A = G->A ;
+     116             :     GrB_Index n ;
+     117        3954 :     GRB_TRY (GrB_Matrix_nrows (&n, A)) ;
+     118        3954 :     LG_ASSERT_MSG (source < n, GrB_INVALID_INDEX, "invalid source node") ;
+     119             : 
+     120             :     //--------------------------------------------------------------------------
+     121             :     // initializations
+     122             :     //--------------------------------------------------------------------------
+     123             : 
+     124             :     // get the type of the A matrix
+     125             :     GrB_Type etype ;
+     126             :     char typename [LAGRAPH_MAX_NAME_LEN] ;
+     127        3954 :     LG_TRY (LAGraph_Matrix_TypeName (typename, A, msg)) ;
+     128        3954 :     LG_TRY (LAGraph_TypeFromName (&etype, typename, msg)) ;
+     129             : 
+     130        3954 :     GRB_TRY (GrB_Scalar_new (&lBound, etype)) ;
+     131        3926 :     GRB_TRY (GrB_Scalar_new (&uBound, etype)) ;
+     132        3898 :     GRB_TRY (GrB_Vector_new (&t, etype, n)) ;
+     133        3870 :     GRB_TRY (GrB_Vector_new (&tmasked, etype, n)) ;
+     134        3842 :     GRB_TRY (GrB_Vector_new (&tReq, etype, n)) ;
+     135        3814 :     GRB_TRY (GrB_Vector_new (&Empty, GrB_BOOL, n)) ;
+     136        3786 :     GRB_TRY (GrB_Vector_new (&tless, GrB_BOOL, n)) ;
+     137        3758 :     GRB_TRY (GrB_Vector_new (&s, GrB_BOOL, n)) ;
+     138        3730 :     GRB_TRY (GrB_Vector_new (&reach, GrB_BOOL, n)) ;
+     139             : 
+     140             : #if LAGRAPH_SUITESPARSE
+     141             :     // optional hints for SuiteSparse:GraphBLAS
+     142        3702 :     GRB_TRY (GxB_set (t, GxB_SPARSITY_CONTROL, GxB_BITMAP)) ;
+     143        3674 :     GRB_TRY (GxB_set (tmasked, GxB_SPARSITY_CONTROL, GxB_SPARSE)) ;
+     144        3674 :     GRB_TRY (GxB_set (tReq, GxB_SPARSITY_CONTROL, GxB_SPARSE)) ;
+     145        3674 :     GRB_TRY (GxB_set (tless, GxB_SPARSITY_CONTROL, GxB_SPARSE)) ;
+     146        3674 :     GRB_TRY (GxB_set (s, GxB_SPARSITY_CONTROL, GxB_SPARSE)) ;
+     147        3674 :     GRB_TRY (GxB_set (reach, GxB_SPARSITY_CONTROL, GxB_BITMAP)) ;
+     148             : #endif
+     149             : 
+     150             :     // select the operators, and set t (:) = infinity
+     151             :     GrB_IndexUnaryOp ne, le, ge, lt, gt ;
+     152             :     GrB_BinaryOp less_than ;
+     153             :     GrB_Semiring min_plus ;
+     154             :     int tcode ;
+     155             :     int32_t  delta_int32  ;
+     156             :     int64_t  delta_int64  ;
+     157             :     uint32_t delta_uint32 ;
+     158             :     uint64_t delta_uint64 ;
+     159             :     float    delta_fp32   ;
+     160             :     double   delta_fp64   ;
+     161             : 
+     162        3646 :     bool negative_edge_weights = true ;
+     163             : 
+     164        3646 :     if (etype == GrB_INT32)
+     165             :     {
+     166        3419 :         GRB_TRY (GrB_Scalar_extractElement (&delta_int32, Delta)) ;
+     167        3419 :         GRB_TRY (GrB_assign (t, NULL, NULL, (int32_t) INT32_MAX,
+     168             :             GrB_ALL, n, NULL)) ;
+     169        3391 :         ne = GrB_VALUENE_INT32 ;
+     170        3391 :         le = GrB_VALUELE_INT32 ;
+     171        3391 :         ge = GrB_VALUEGE_INT32 ;
+     172        3391 :         lt = GrB_VALUELT_INT32 ;
+     173        3391 :         gt = GrB_VALUEGT_INT32 ;
+     174        3391 :         less_than = GrB_LT_INT32 ;
+     175        3391 :         min_plus = GrB_MIN_PLUS_SEMIRING_INT32 ;
+     176        3391 :         tcode = 0 ;
+     177             :     }
+     178         227 :     else if (etype == GrB_INT64)
+     179             :     {
+     180          48 :         GRB_TRY (GrB_Scalar_extractElement (&delta_int64, Delta)) ;
+     181          48 :         GRB_TRY (GrB_assign (t, NULL, NULL, (int64_t) INT64_MAX,
+     182             :             GrB_ALL, n, NULL)) ;
+     183          48 :         ne = GrB_VALUENE_INT64 ;
+     184          48 :         le = GrB_VALUELE_INT64 ;
+     185          48 :         ge = GrB_VALUEGE_INT64 ;
+     186          48 :         lt = GrB_VALUELT_INT64 ;
+     187          48 :         gt = GrB_VALUEGT_INT64 ;
+     188          48 :         less_than = GrB_LT_INT64 ;
+     189          48 :         min_plus = GrB_MIN_PLUS_SEMIRING_INT64 ;
+     190          48 :         tcode = 1 ;
+     191             :     }
+     192         179 :     else if (etype == GrB_UINT32)
+     193             :     {
+     194          12 :         GRB_TRY (GrB_Scalar_extractElement (&delta_uint32, Delta)) ;
+     195          12 :         GRB_TRY (GrB_assign (t, NULL, NULL, (uint32_t) UINT32_MAX,
+     196             :             GrB_ALL, n, NULL)) ;
+     197          12 :         ne = GrB_VALUENE_UINT32 ;
+     198          12 :         le = GrB_VALUELE_UINT32 ;
+     199          12 :         ge = GrB_VALUEGE_UINT32 ;
+     200          12 :         lt = GrB_VALUELT_UINT32 ;
+     201          12 :         gt = GrB_VALUEGT_UINT32 ;
+     202          12 :         less_than = GrB_LT_UINT32 ;
+     203          12 :         min_plus = GrB_MIN_PLUS_SEMIRING_UINT32 ;
+     204          12 :         tcode = 2 ;
+     205          12 :         negative_edge_weights = false ;
+     206             :     }
+     207         167 :     else if (etype == GrB_UINT64)
+     208             :     {
+     209          12 :         GRB_TRY (GrB_Scalar_extractElement (&delta_uint64, Delta)) ;
+     210          12 :         GRB_TRY (GrB_assign (t, NULL, NULL, (uint64_t) UINT64_MAX,
+     211             :             GrB_ALL, n, NULL)) ;
+     212          12 :         ne = GrB_VALUENE_UINT64 ;
+     213          12 :         le = GrB_VALUELE_UINT64 ;
+     214          12 :         ge = GrB_VALUEGE_UINT64 ;
+     215          12 :         lt = GrB_VALUELT_UINT64 ;
+     216          12 :         gt = GrB_VALUEGT_UINT64 ;
+     217          12 :         less_than = GrB_LT_UINT64 ;
+     218          12 :         min_plus = GrB_MIN_PLUS_SEMIRING_UINT64 ;
+     219          12 :         tcode = 3 ;
+     220          12 :         negative_edge_weights = false ;
+     221             :     }
+     222         155 :     else if (etype == GrB_FP32)
+     223             :     {
+     224           9 :         GRB_TRY (GrB_Scalar_extractElement (&delta_fp32, Delta)) ;
+     225           9 :         GRB_TRY (GrB_assign (t, NULL, NULL, (float) INFINITY,
+     226             :             GrB_ALL, n, NULL)) ;
+     227           9 :         ne = GrB_VALUENE_FP32 ;
+     228           9 :         le = GrB_VALUELE_FP32 ;
+     229           9 :         ge = GrB_VALUEGE_FP32 ;
+     230           9 :         lt = GrB_VALUELT_FP32 ;
+     231           9 :         gt = GrB_VALUEGT_FP32 ;
+     232           9 :         less_than = GrB_LT_FP32 ;
+     233           9 :         min_plus = GrB_MIN_PLUS_SEMIRING_FP32 ;
+     234           9 :         tcode = 4 ;
+     235             :     }
+     236         146 :     else if (etype == GrB_FP64)
+     237             :     {
+     238         145 :         GRB_TRY (GrB_Scalar_extractElement (&delta_fp64, Delta)) ;
+     239         145 :         GRB_TRY (GrB_assign (t, NULL, NULL, (double) INFINITY,
+     240             :             GrB_ALL, n, NULL)) ;
+     241         145 :         ne = GrB_VALUENE_FP64 ;
+     242         145 :         le = GrB_VALUELE_FP64 ;
+     243         145 :         ge = GrB_VALUEGE_FP64 ;
+     244         145 :         lt = GrB_VALUELT_FP64 ;
+     245         145 :         gt = GrB_VALUEGT_FP64 ;
+     246         145 :         less_than = GrB_LT_FP64 ;
+     247         145 :         min_plus = GrB_MIN_PLUS_SEMIRING_FP64 ;
+     248         145 :         tcode = 5 ;
+     249             :     }
+     250             :     else
+     251             :     {
+     252           1 :         LG_ASSERT_MSG (false, GrB_NOT_IMPLEMENTED, "type not supported") ;
+     253             :     }
+     254             : 
+     255             :     // check if the graph might have negative edge weights
+     256        3617 :     if (negative_edge_weights)
+     257             :     {
+     258        3593 :         double emin = -1 ;
+     259        3593 :         if (G->emin != NULL &&
+     260         452 :             (G->emin_state == LAGraph_VALUE ||
+     261         238 :              G->emin_state == LAGraph_BOUND))
+     262             :         {
+     263         214 :             GRB_TRY (GrB_Scalar_extractElement_FP64 (&emin, G->emin)) ;
+     264             :         }
+     265             : //      else
+     266             : //      {
+     267             : //          // a future Basic algorithm should compute G->emin and perhaps
+     268             : //          // G->emax, then compute Delta automatically.
+     269             : //      }
+     270        3593 :         negative_edge_weights = (emin < 0) ;
+     271             :     }
+     272             : 
+     273             :     // t (src) = 0
+     274        3617 :     GRB_TRY (GrB_Vector_setElement (t, 0, source)) ;
+     275             : 
+     276             :     // reach (src) = true
+     277        3603 :     GRB_TRY (GrB_Vector_setElement (reach, true, source)) ;
+     278             : 
+     279             :     // s (src) = true
+     280        3589 :     GRB_TRY (GrB_Vector_setElement (s, true, source)) ;
+     281             : 
+     282             :     // AL = A .* (A <= Delta)
+     283        3547 :     GRB_TRY (GrB_Matrix_new (&AL, etype, n, n)) ;
+     284        3505 :     GRB_TRY (GrB_select (AL, NULL, NULL, le, A, Delta, NULL)) ;
+     285        3454 :     GRB_TRY (GrB_wait (AL, GrB_MATERIALIZE)) ;
+     286             : 
+     287             :     // FUTURE: costly for some problems, taking up to 50% of the total time:
+     288             :     // AH = A .* (A > Delta)
+     289        3454 :     GRB_TRY (GrB_Matrix_new (&AH, etype, n, n)) ;
+     290        3412 :     GRB_TRY (GrB_select (AH, NULL, NULL, gt, A, Delta, NULL)) ;
+     291        3336 :     GRB_TRY (GrB_wait (AH, GrB_MATERIALIZE)) ;
+     292             : 
+     293             :     //--------------------------------------------------------------------------
+     294             :     // while (t >= step*Delta) not empty
+     295             :     //--------------------------------------------------------------------------
+     296             : 
+     297        3336 :     for (int64_t step = 0 ; ; step++)
+     298        9573 :     {
+     299             : 
+     300             :         //----------------------------------------------------------------------
+     301             :         // tmasked = all entries in t<reach> that are less than (step+1)*Delta
+     302             :         //----------------------------------------------------------------------
+     303             : 
+     304       12909 :         setelement (uBound, (step+1)) ;        // uBound = (step+1) * Delta
+     305       15596 :         GRB_TRY (GrB_Vector_clear (tmasked)) ;
+     306             : 
+     307             :         // tmasked<reach> = t
+     308             :         // FUTURE: this is costly, typically using Method 06s in SuiteSparse,
+     309             :         // which is a very general-purpose one.  Write a specialized kernel to
+     310             :         // exploit the fact that reach and t are bitmap and tmasked starts
+     311             :         // empty, or fuse this assignment with the GrB_select below.
+     312       12779 :         GRB_TRY (GrB_assign (tmasked, reach, NULL, t, GrB_ALL, n, NULL)) ;
+     313             :         // tmasked = select (tmasked < (step+1)*Delta)
+     314       12511 :         GRB_TRY (GrB_select (tmasked, NULL, NULL, lt, tmasked, uBound, NULL)) ;
+     315             :         // --- alternative:
+     316             :         // FUTURE this is slower than the above but should be much faster.
+     317             :         // GrB_select is computing a bitmap result then converting it to
+     318             :         // sparse.  t and reach are both bitmap and tmasked finally sparse.
+     319             :         // tmasked<reach> = select (t < (step+1)*Delta)
+     320             :         // GRB_TRY (GrB_select (tmasked, reach, NULL, lt, t, uBound, NULL)) ;
+     321             : 
+     322             :         GrB_Index tmasked_nvals ;
+     323       12343 :         GRB_TRY (GrB_Vector_nvals (&tmasked_nvals, tmasked)) ;
+     324             : 
+     325             :         //----------------------------------------------------------------------
+     326             :         // continue while the current bucket (tmasked) is not empty
+     327             :         //----------------------------------------------------------------------
+     328             : 
+     329       25660 :         while (tmasked_nvals > 0)
+     330             :         {
+     331             :             // tReq = AL'*tmasked using the min_plus semiring
+     332       20033 :             GRB_TRY (GrB_vxm (tReq, NULL, NULL, min_plus, tmasked, AL, NULL)) ;
+     333             : 
+     334             :             // s<struct(tmasked)> = true
+     335       18360 :             GRB_TRY (GrB_assign (s, tmasked, NULL, (bool) true, GrB_ALL, n,
+     336             :                 GrB_DESC_S)) ;
+     337             : 
+     338             :             // if nvals (tReq) is 0, no need to continue the rest of this loop
+     339             :             GrB_Index tReq_nvals ;
+     340       18153 :             GRB_TRY (GrB_Vector_nvals (&tReq_nvals, tReq)) ;
+     341       20223 :             if (tReq_nvals == 0) break ;
+     342             : 
+     343             :             // tless = (tReq .< t) using set intersection
+     344       16523 :             GRB_TRY (GrB_eWiseMult (tless, NULL, NULL, less_than, tReq, t,
+     345             :                 NULL)) ;
+     346             : 
+     347             :             // remove explicit zeros from tless so it can be used as a
+     348             :             // structural mask
+     349             :             GrB_Index tless_nvals ;
+     350       16310 :             GRB_TRY (GrB_select (tless, NULL, NULL, ne, tless, 0, NULL)) ;
+     351       16103 :             GRB_TRY (GrB_Vector_nvals (&tless_nvals, tless)) ;
+     352       16103 :             if (tless_nvals == 0) break ;
+     353             : 
+     354             :             // update reachable node list/mask
+     355             :             // reach<struct(tless)> = true
+     356       14033 :             GRB_TRY (GrB_assign (reach, tless, NULL, (bool) true, GrB_ALL, n,
+     357             :                 GrB_DESC_S)) ;
+     358             : 
+     359             :             // tmasked<struct(tless)> = select (tReq < (step+1)*Delta)
+     360       14033 :             GRB_TRY (GrB_Vector_clear (tmasked)) ;
+     361       13985 :             GRB_TRY (GrB_select (tmasked, tless, NULL, lt, tReq, uBound,
+     362             :                 GrB_DESC_S)) ;
+     363             : 
+     364             :             // For general graph with some negative weights:
+     365       13581 :             if (negative_edge_weights)
+     366             :             {
+     367             :                 // If all entries of the graph are known to be positive, and
+     368             :                 // the entries of tmasked are at least step*Delta, tReq =
+     369             :                 // tmasked min.+ AL must be >= step*Delta.  Therefore, there is
+     370             :                 // no need to perform this GrB_select with ge to find tmasked
+     371             :                 // >= step*Delta from tReq.
+     372       10710 :                 setelement (lBound, (step)) ;  // lBound = step*Delta
+     373             :                 // tmasked = select entries in tmasked that are >= step*Delta
+     374       10710 :                 GRB_TRY (GrB_select (tmasked, NULL, NULL, ge, tmasked, lBound,
+     375             :                     NULL)) ;
+     376             :             }
+     377             : 
+     378             :             // t<struct(tless)> = tReq
+     379       13317 :             GRB_TRY (GrB_assign (t, tless, NULL, tReq, GrB_ALL, n, GrB_DESC_S));
+     380       13317 :             GRB_TRY (GrB_Vector_nvals (&tmasked_nvals, tmasked)) ;
+     381             :         }
+     382             : 
+     383             :         // tmasked<s> = t
+     384       10670 :         GRB_TRY (GrB_Vector_clear (tmasked)) ;
+     385       10638 :         GRB_TRY (GrB_assign (tmasked, s, NULL, t, GrB_ALL, n, GrB_DESC_S)) ;
+     386             : 
+     387             :         // tReq = AH'*tmasked using the min_plus semiring
+     388       10404 :         GRB_TRY (GrB_vxm (tReq, NULL, NULL, min_plus, tmasked, AH, NULL)) ;
+     389             : 
+     390             :         // tless = (tReq .< t) using set intersection
+     391       10212 :         GRB_TRY (GrB_eWiseMult (tless, NULL, NULL, less_than, tReq, t, NULL)) ;
+     392             : 
+     393             :         // t<tless> = tReq, which computes t = min (t, tReq)
+     394       10116 :         GRB_TRY (GrB_assign (t, tless, NULL, tReq, GrB_ALL, n, NULL)) ;
+     395             : 
+     396             :         //----------------------------------------------------------------------
+     397             :         // find out how many left to be computed
+     398             :         //----------------------------------------------------------------------
+     399             : 
+     400             :         // update reachable node list
+     401             :         // reach<tless> = true
+     402       10116 :         GRB_TRY (GrB_assign (reach, tless, NULL, (bool) true, GrB_ALL, n,
+     403             :             NULL)) ;
+     404             : 
+     405             :         // remove previous buckets
+     406             :         // reach<struct(s)> = Empty
+     407       10116 :         GRB_TRY (GrB_assign (reach, s, NULL, Empty, GrB_ALL, n, GrB_DESC_S)) ;
+     408             :         GrB_Index nreach ;
+     409       10110 :         GRB_TRY (GrB_Vector_nvals (&nreach, reach)) ;
+     410       10110 :         if (nreach == 0) break ;
+     411             : 
+     412        9591 :         GRB_TRY (GrB_Vector_clear (s)) ; // clear s for the next iteration
+     413             :     }
+     414             : 
+     415             :     //--------------------------------------------------------------------------
+     416             :     // free workspace and return result
+     417             :     //--------------------------------------------------------------------------
+     418             : 
+     419         519 :     (*path_length) = t ;
+     420         519 :     LG_FREE_WORK ;
+     421         519 :     return (GrB_SUCCESS) ;
+     422             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/algorithm/LAGr_TriangleCount.c.func-sort-c.html b/src/algorithm/LAGr_TriangleCount.c.func-sort-c.html new file mode 100644 index 0000000000..31fe1aff3c --- /dev/null +++ b/src/algorithm/LAGr_TriangleCount.c.func-sort-c.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/algorithm/LAGr_TriangleCount.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/algorithm - LAGr_TriangleCount.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:103103100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
tricount_prep3074
LAGr_TriangleCount4401
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/algorithm/LAGr_TriangleCount.c.func.html b/src/algorithm/LAGr_TriangleCount.c.func.html new file mode 100644 index 0000000000..fb6e587960 --- /dev/null +++ b/src/algorithm/LAGr_TriangleCount.c.func.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/algorithm/LAGr_TriangleCount.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/algorithm - LAGr_TriangleCount.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:103103100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGr_TriangleCount4401
tricount_prep3074
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/algorithm/LAGr_TriangleCount.c.gcov.html b/src/algorithm/LAGr_TriangleCount.c.gcov.html new file mode 100644 index 0000000000..0017ceac02 --- /dev/null +++ b/src/algorithm/LAGr_TriangleCount.c.gcov.html @@ -0,0 +1,442 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/algorithm/LAGr_TriangleCount.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/algorithm - LAGr_TriangleCount.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:103103100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGr_TriangleCount: Triangle counting using various methods
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // Count the number of triangles in a graph,
+      19             : 
+      20             : // This is an Advanced algorithm (G->nself_edges, G->out_degree,
+      21             : // G->is_symmetric_structure are required).
+      22             : 
+      23             : // Given a symmetric graph A with no-self edges, LAGr_TriangleCount counts the
+      24             : // number of triangles in the graph.  A triangle is a clique of size three,
+      25             : // that is, 3 nodes that are all pairwise connected.
+      26             : 
+      27             : // One of 6 methods are used, defined below where L and U are the strictly
+      28             : // lower and strictly upper triangular parts of the symmetrix matrix A,
+      29             : // respectively.  Each method computes the same result, ntri:
+      30             : 
+      31             : //  0:  default:    use the default method (currently method Sandia_LUT)
+      32             : //  1:  Burkhardt:  ntri = sum (sum ((A^2) .* A)) / 6
+      33             : //  2:  Cohen:      ntri = sum (sum ((L * U) .* A)) / 2
+      34             : //  3:  Sandia_LL:  ntri = sum (sum ((L * L) .* L))
+      35             : //  4:  Sandia_UU:  ntri = sum (sum ((U * U) .* U))
+      36             : //  5:  Sandia_LUT: ntri = sum (sum ((L * U') .* L)).  Note that L=U'.
+      37             : //  6:  Sandia_ULT: ntri = sum (sum ((U * L') .* U)).  Note that U=L'.
+      38             : 
+      39             : // A is a square symmetric matrix, of any type.  Its values are ignored.
+      40             : // Results are undefined for methods 1 and 2 if self-edges exist in A.  Results
+      41             : // are undefined for all methods if A is unsymmetric.
+      42             : 
+      43             : // The Sandia_* methods all tend to be faster than the Burkhardt or Cohen
+      44             : // methods.  For the largest graphs, Sandia_LUT tends to be fastest, except for
+      45             : // the GAP-urand matrix, where the saxpy-based Sandia_LL method (L*L.*L) is
+      46             : // fastest.  For many small graphs, the saxpy-based Sandia_LL and Sandia_UU
+      47             : // methods are often faster that the dot-product-based methods.
+      48             : 
+      49             : // Reference for the Burkhardt method:  Burkhardt, Paul. "Graphing Trillions of
+      50             : // Triangles." Information Visualization 16, no. 3 (July 2017): 157–66.
+      51             : // https://doi.org/10.1177/1473871616666393.
+      52             : 
+      53             : // Reference for the Cohen method:  J. Cohen, "Graph twiddling in a mapreduce
+      54             : // world," Computing in Science & Engineering, vol. 11, no. 4, pp. 29–41, 2009.
+      55             : // https://doi.org/10.1109/MCSE.2009.120
+      56             : 
+      57             : // Reference for the "Sandia_*" methods: Wolf, Deveci, Berry, Hammond,
+      58             : // Rajamanickam, "Fast linear algebra- based triangle counting with
+      59             : // KokkosKernels", IEEE HPEC'17, https://dx.doi.org/10.1109/HPEC.2017.8091043
+      60             : 
+      61             : #define LG_FREE_ALL             \
+      62             : {                               \
+      63             :     GrB_free (L) ;              \
+      64             :     GrB_free (U) ;              \
+      65             : }
+      66             : 
+      67             : #include "LG_internal.h"
+      68             : 
+      69             : //------------------------------------------------------------------------------
+      70             : // tricount_prep: construct L and U for LAGr_TriangleCount
+      71             : //------------------------------------------------------------------------------
+      72             : 
+      73        3074 : static int tricount_prep
+      74             : (
+      75             :     GrB_Matrix *L,      // if present, compute L = tril (A,-1)
+      76             :     GrB_Matrix *U,      // if present, compute U = triu (A, 1)
+      77             :     GrB_Matrix A,       // input matrix
+      78             :     char *msg
+      79             : )
+      80             : {
+      81             :     GrB_Index n ;
+      82        3074 :     GRB_TRY (GrB_Matrix_nrows (&n, A)) ;
+      83             : 
+      84        3074 :     if (L != NULL)
+      85             :     {
+      86             :         // L = tril (A,-1)
+      87        2714 :         GRB_TRY (GrB_Matrix_new (L, GrB_BOOL, n, n)) ;
+      88        2282 :         GRB_TRY (GrB_select (*L, NULL, NULL, GrB_TRIL, A, (int64_t) (-1),
+      89             :             NULL)) ;
+      90        1823 :         GRB_TRY (GrB_Matrix_wait (*L, GrB_MATERIALIZE)) ;
+      91             :     }
+      92             : 
+      93        2183 :     if (U != NULL)
+      94             :     {
+      95             :         // U = triu (A,1)
+      96        1986 :         GRB_TRY (GrB_Matrix_new (U, GrB_BOOL, n, n)) ;
+      97        1527 :         GRB_TRY (GrB_select (*U, NULL, NULL, GrB_TRIU, A, (int64_t) 1, NULL)) ;
+      98        1054 :         GRB_TRY (GrB_Matrix_wait (*U, GrB_MATERIALIZE)) ;
+      99             :     }
+     100        1251 :     return (GrB_SUCCESS) ;
+     101             : }
+     102             : 
+     103             : //------------------------------------------------------------------------------
+     104             : // LAGraph_tricount: count the number of triangles in a graph
+     105             : //------------------------------------------------------------------------------
+     106             : 
+     107             : #undef  LG_FREE_ALL
+     108             : #define LG_FREE_ALL                         \
+     109             : {                                           \
+     110             :     GrB_free (&C) ;                         \
+     111             :     GrB_free (&L) ;                         \
+     112             :     GrB_free (&T) ;                         \
+     113             :     GrB_free (&U) ;                         \
+     114             :     LAGraph_Free ((void **) &P, NULL) ;     \
+     115             : }
+     116             : 
+     117        4401 : int LAGr_TriangleCount
+     118             : (
+     119             :     // output:
+     120             :     uint64_t *ntriangles,
+     121             :     // input:
+     122             :     const LAGraph_Graph G,
+     123             :     LAGr_TriangleCount_Method *p_method,
+     124             :     LAGr_TriangleCount_Presort *p_presort,
+     125             :     char *msg
+     126             : )
+     127             : {
+     128             : 
+     129             :     //--------------------------------------------------------------------------
+     130             :     // check inputs
+     131             :     //--------------------------------------------------------------------------
+     132             : 
+     133        4401 :     LG_CLEAR_MSG ;
+     134        4401 :     GrB_Matrix C = NULL, L = NULL, U = NULL, T = NULL ;
+     135        4401 :     int64_t *P = NULL ;
+     136             : 
+     137             :     // get the method
+     138             :     LAGr_TriangleCount_Method method ;
+     139        4401 :     method = (p_method == NULL) ? LAGr_TriangleCount_AutoMethod : (*p_method) ;
+     140        4401 :     LG_ASSERT_MSG (
+     141             :     method == LAGr_TriangleCount_AutoMethod ||  // 0: use auto method
+     142             :     method == LAGr_TriangleCount_Burkhardt  ||  // 1: sum (sum ((A^2) .* A))/6
+     143             :     method == LAGr_TriangleCount_Cohen      ||  // 2: sum (sum ((L * U) .*A))/2
+     144             :     method == LAGr_TriangleCount_Sandia_LL  ||  // 3: sum (sum ((L * L) .* L))
+     145             :     method == LAGr_TriangleCount_Sandia_UU  ||  // 4: sum (sum ((U * U) .* U))
+     146             :     method == LAGr_TriangleCount_Sandia_LUT ||  // 5: sum (sum ((L * U') .* L))
+     147             :     method == LAGr_TriangleCount_Sandia_ULT,    // 6: sum (sum ((U * L') .* U))
+     148             :     GrB_INVALID_VALUE, "method is invalid") ;
+     149             : 
+     150             :     // get the presort
+     151             :     LAGr_TriangleCount_Presort presort ;
+     152        4392 :     presort = (p_presort == NULL) ? LAGr_TriangleCount_AutoSort : (*p_presort) ;
+     153        4392 :     LG_ASSERT_MSG (
+     154             :     presort == LAGr_TriangleCount_NoSort     ||
+     155             :     presort == LAGr_TriangleCount_Ascending  ||
+     156             :     presort == LAGr_TriangleCount_Descending ||
+     157             :     presort == LAGr_TriangleCount_AutoSort,
+     158             :     GrB_INVALID_VALUE, "presort is invalid") ;
+     159             : 
+     160        4383 :     LG_TRY (LAGraph_CheckGraph (G, msg)) ;
+     161        4383 :     LG_ASSERT (ntriangles != NULL, GrB_NULL_POINTER) ;
+     162        4383 :     LG_ASSERT (G->nself_edges == 0, LAGRAPH_NO_SELF_EDGES_ALLOWED) ;
+     163             : 
+     164        4383 :     LG_ASSERT_MSG ((G->kind == LAGraph_ADJACENCY_UNDIRECTED ||
+     165             :        (G->kind == LAGraph_ADJACENCY_DIRECTED &&
+     166             :         G->is_symmetric_structure == LAGraph_TRUE)),
+     167             :         LAGRAPH_SYMMETRIC_STRUCTURE_REQUIRED,
+     168             :         "G->A must be known to be symmetric") ;
+     169             : 
+     170        4383 :     if (method == LAGr_TriangleCount_AutoMethod)
+     171             :     {
+     172             :         // AutoMethod: use default, Sandia_LUT: sum (sum ((L * U') .* L))
+     173        1040 :         method = LAGr_TriangleCount_Sandia_LUT ;
+     174             :     }
+     175             : 
+     176             :     // only the Sandia_* methods can benefit from the presort
+     177        4383 :     bool method_can_use_presort =
+     178        3836 :     method == LAGr_TriangleCount_Sandia_LL || // sum (sum ((L * L) .* L))
+     179        3289 :     method == LAGr_TriangleCount_Sandia_UU || // sum (sum ((U * U) .* U))
+     180        8219 :     method == LAGr_TriangleCount_Sandia_LUT || // sum (sum ((L * U') .* L))
+     181             :     method == LAGr_TriangleCount_Sandia_ULT ; // sum (sum ((U * L') .* U))
+     182             : 
+     183        4383 :     GrB_Matrix A = G->A ;
+     184        4383 :     GrB_Vector Degree = G->out_degree ;
+     185             : 
+     186        4383 :     bool auto_sort = (presort == LAGr_TriangleCount_AutoSort) ;
+     187        4383 :     if (auto_sort && method_can_use_presort)
+     188             :     {
+     189        1258 :         LG_ASSERT_MSG (Degree != NULL,
+     190             :             LAGRAPH_NOT_CACHED, "G->out_degree is required") ;
+     191             :     }
+     192             : 
+     193             :     //--------------------------------------------------------------------------
+     194             :     // initializations
+     195             :     //--------------------------------------------------------------------------
+     196             : 
+     197             :     GrB_Index n ;
+     198        4379 :     GRB_TRY (GrB_Matrix_nrows (&n, A)) ;
+     199        4379 :     GRB_TRY (GrB_Matrix_new (&C, GrB_INT64, n, n)) ;
+     200             :     #if LAGRAPH_SUITESPARSE
+     201        3776 :     GrB_Semiring semiring = GxB_PLUS_PAIR_INT64 ;
+     202             :     #else
+     203             :     GrB_Semiring semiring = LAGraph_plus_one_int64 ;
+     204             :     #endif
+     205        3776 :     GrB_Monoid monoid = GrB_PLUS_MONOID_INT64 ;
+     206             : 
+     207             :     //--------------------------------------------------------------------------
+     208             :     // heuristic sort rule
+     209             :     //--------------------------------------------------------------------------
+     210             : 
+     211        3776 :     if (!method_can_use_presort)
+     212             :     {
+     213             :         // no sorting for the Burkhardt and Cohen methods: presort parameter
+     214             :         // is ignored.
+     215         691 :         presort = LAGr_TriangleCount_NoSort ;
+     216             :     }
+     217        3085 :     else if (auto_sort)
+     218             :     {
+     219             :         // auto selection of sorting method for Sandia_* methods
+     220        1083 :         presort = LAGr_TriangleCount_NoSort ; // default is not to sort
+     221             : 
+     222        1083 :         if (method_can_use_presort)
+     223             :         {
+     224             :             // This rule is very similar to Scott Beamer's rule in the GAP TC
+     225             :             // benchmark, except that it is extended to handle the ascending
+     226             :             // sort needed by methods 3 and 5.  It also uses a stricter rule,
+     227             :             // since the performance of triangle counting in SuiteSparse:
+     228             :             // GraphBLAS is less sensitive to the sorting as compared to the
+     229             :             // GAP algorithm.  This is because the dot products in SuiteSparse:
+     230             :             // GraphBLAS use binary search if one vector is very sparse
+     231             :             // compared to the other.  As a result, SuiteSparse:GraphBLAS needs
+     232             :             // the sort for fewer matrices, as compared to the GAP algorithm.
+     233             : 
+     234             :             // With this rule, the GAP-kron and GAP-twitter matrices are
+     235             :             // sorted, and the others remain unsorted.  With the rule in the
+     236             :             // GAP tc.cc benchmark, GAP-kron and GAP-twitter are sorted, and so
+     237             :             // is GAP-web, but GAP-web is not sorted here.
+     238             : 
+     239             :             #define NSAMPLES 1000
+     240             :             GrB_Index nvals ;
+     241        1089 :             GRB_TRY (GrB_Matrix_nvals (&nvals, A)) ;
+     242        1083 :             if (n > NSAMPLES && ((double) nvals / ((double) n)) >= 10)
+     243             :             {
+     244             :                 // estimate the mean and median degrees
+     245             :                 double mean, median ;
+     246         156 :                 LG_TRY (LAGr_SampleDegree (&mean, &median,
+     247             :                     G, true, NSAMPLES, n, msg)) ;
+     248             :                 // sort if the average degree is very high vs the median
+     249         150 :                 if (mean > 4 * median)
+     250             :                 {
+     251           6 :                     switch (method)
+     252             :                     {
+     253           1 :                         case LAGr_TriangleCount_Sandia_LL:
+     254             :                             // 3:sum (sum ((L * L) .* L))
+     255           1 :                             presort = LAGr_TriangleCount_Ascending  ;
+     256           1 :                             break ;
+     257           1 :                         case LAGr_TriangleCount_Sandia_UU:
+     258             :                             // 4: sum (sum ((U * U) .* U))
+     259           1 :                             presort = LAGr_TriangleCount_Descending ;
+     260           1 :                             break ;
+     261           3 :                         default:
+     262             :                         case LAGr_TriangleCount_Sandia_LUT:
+     263             :                             // 5: sum (sum ((L * U') .* L))
+     264           3 :                             presort = LAGr_TriangleCount_Ascending  ;
+     265           3 :                             break ;
+     266           1 :                         case LAGr_TriangleCount_Sandia_ULT:
+     267             :                             // 6: sum (sum ((U * L') .* U))
+     268           1 :                             presort = LAGr_TriangleCount_Descending ;
+     269           1 :                             break ;
+     270             :                     }
+     271             :                 }
+     272             :             }
+     273             :         }
+     274             :     }
+     275             : 
+     276             :     //--------------------------------------------------------------------------
+     277             :     // sort the input matrix, if requested
+     278             :     //--------------------------------------------------------------------------
+     279             : 
+     280        3770 :     if (presort != LAGr_TriangleCount_NoSort)
+     281             :     {
+     282             :         // P = permutation that sorts the rows by their degree
+     283        1247 :         LG_TRY (LAGr_SortByDegree (&P, G, true,
+     284             :             presort == LAGr_TriangleCount_Ascending, msg)) ;
+     285             : 
+     286             :         // T = A (P,P) and typecast to boolean
+     287        1112 :         GRB_TRY (GrB_Matrix_new (&T, GrB_BOOL, n, n)) ;
+     288         977 :         GRB_TRY (GrB_extract (T, NULL, NULL, A, (GrB_Index *) P, n,
+     289             :             (GrB_Index *) P, n, NULL)) ;
+     290         727 :         A = T ;
+     291             : 
+     292             :         // free workspace
+     293         727 :         LG_TRY (LAGraph_Free ((void **) &P, NULL)) ;
+     294             :     }
+     295             : 
+     296             :     //--------------------------------------------------------------------------
+     297             :     // count triangles
+     298             :     //--------------------------------------------------------------------------
+     299             : 
+     300             :     int64_t ntri ;
+     301             : 
+     302        3250 :     switch (method)
+     303             :     {
+     304             : 
+     305         176 :         case LAGr_TriangleCount_Burkhardt:  // 1: sum (sum ((A^2) .* A)) / 6
+     306             : 
+     307         176 :             GRB_TRY (GrB_mxm (C, A, NULL, semiring, A, A, GrB_DESC_S)) ;
+     308          56 :             GRB_TRY (GrB_reduce (&ntri, NULL, monoid, C, NULL)) ;
+     309          56 :             ntri /= 6 ;
+     310          56 :             break ;
+     311             : 
+     312         515 :         case LAGr_TriangleCount_Cohen: // 2: sum (sum ((L * U) .* A)) / 2
+     313             : 
+     314         515 :             LG_TRY (tricount_prep (&L, &U, A, msg)) ;
+     315         179 :             GRB_TRY (GrB_mxm (C, A, NULL, semiring, L, U, GrB_DESC_S)) ;
+     316          56 :             GRB_TRY (GrB_reduce (&ntri, NULL, monoid, C, NULL)) ;
+     317          56 :             ntri /= 2 ;
+     318          56 :             break ;
+     319             : 
+     320         360 :         case LAGr_TriangleCount_Sandia_LL: // 3: sum (sum ((L * L) .* L))
+     321             : 
+     322             :             // using the masked saxpy3 method
+     323         360 :             LG_TRY (tricount_prep (&L, NULL, A, msg)) ;
+     324         197 :             GRB_TRY (GrB_mxm (C, L, NULL, semiring, L, L, GrB_DESC_S)) ;
+     325          56 :             GRB_TRY (GrB_reduce (&ntri, NULL, monoid, C, NULL)) ;
+     326          56 :             break ;
+     327             : 
+     328         360 :         case LAGr_TriangleCount_Sandia_UU: // 4: sum (sum ((U * U) .* U))
+     329             : 
+     330             :             // using the masked saxpy3 method
+     331         360 :             LG_TRY (tricount_prep (NULL, &U, A, msg)) ;
+     332         197 :             GRB_TRY (GrB_mxm (C, U, NULL, semiring, U, U, GrB_DESC_S)) ;
+     333          56 :             GRB_TRY (GrB_reduce (&ntri, NULL, monoid, C, NULL)) ;
+     334          56 :             break ;
+     335             : 
+     336        1328 :         default:
+     337             :         case LAGr_TriangleCount_Sandia_LUT: // 5: sum (sum ((L * U') .* L))
+     338             : 
+     339             :             // This tends to be the fastest method for most large matrices, but
+     340             :             // the Sandia_ULT method is also very fast.
+     341             : 
+     342             :             // using the masked dot product
+     343        1328 :             LG_TRY (tricount_prep (&L, &U, A, msg)) ;
+     344         493 :             GRB_TRY (GrB_mxm (C, L, NULL, semiring, L, U, GrB_DESC_ST1)) ;
+     345         149 :             GRB_TRY (GrB_reduce (&ntri, NULL, monoid, C, NULL)) ;
+     346         149 :             break ;
+     347             : 
+     348         511 :         case LAGr_TriangleCount_Sandia_ULT: // 6: sum (sum ((U * L') .* U))
+     349             : 
+     350             :             // using the masked dot product
+     351         511 :             LG_TRY (tricount_prep (&L, &U, A, msg)) ;
+     352         185 :             GRB_TRY (GrB_mxm (C, U, NULL, semiring, U, L, GrB_DESC_ST1)) ;
+     353          56 :             GRB_TRY (GrB_reduce (&ntri, NULL, monoid, C, NULL)) ;
+     354          56 :             break ;
+     355             :     }
+     356             : 
+     357             :     //--------------------------------------------------------------------------
+     358             :     // return result
+     359             :     //--------------------------------------------------------------------------
+     360             : 
+     361         429 :     LG_FREE_ALL ;
+     362         429 :     if (p_method != NULL) (*p_method) = method ;
+     363         429 :     if (p_presort != NULL) (*p_presort) = presort ;
+     364         429 :     (*ntriangles) = (uint64_t) ntri ;
+     365         429 :     return (GrB_SUCCESS) ;
+     366             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/algorithm/LAGraph_TriangleCount.c.func-sort-c.html b/src/algorithm/LAGraph_TriangleCount.c.func-sort-c.html new file mode 100644 index 0000000000..df1ec9884d --- /dev/null +++ b/src/algorithm/LAGraph_TriangleCount.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/algorithm/LAGraph_TriangleCount.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/algorithm - LAGraph_TriangleCount.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:55100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_TriangleCount404
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/algorithm/LAGraph_TriangleCount.c.func.html b/src/algorithm/LAGraph_TriangleCount.c.func.html new file mode 100644 index 0000000000..3e21e5cf96 --- /dev/null +++ b/src/algorithm/LAGraph_TriangleCount.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/algorithm/LAGraph_TriangleCount.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/algorithm - LAGraph_TriangleCount.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:55100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_TriangleCount404
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/algorithm/LAGraph_TriangleCount.c.gcov.html b/src/algorithm/LAGraph_TriangleCount.c.gcov.html new file mode 100644 index 0000000000..e3d48bc9b0 --- /dev/null +++ b/src/algorithm/LAGraph_TriangleCount.c.gcov.html @@ -0,0 +1,122 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/algorithm/LAGraph_TriangleCount.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/algorithm - LAGraph_TriangleCount.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:55100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_TriangleCount:  triangle counting dispatch, basic API
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Scott McMillan, SEI Carnegie Mellon University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // This is a Basic algorithm (G->nself_edges, G->out_degree,
+      19             : // G->is_symmetric_structure are computed, if not present).
+      20             : 
+      21             : #define LG_FREE_ALL ;
+      22             : 
+      23             : #include <LAGraph.h>
+      24             : #include "LG_internal.h"
+      25             : #include "LG_alg_internal.h"
+      26             : 
+      27             : // Pick the default method with auto presort.  Compute G->nself_edges, and
+      28             : // G->out_degree if needed.  Determine if G->A is symmetric, if not known.
+      29             : 
+      30         404 : int LAGraph_TriangleCount
+      31             : (
+      32             :     // output:
+      33             :     uint64_t *ntriangles,   // number of triangles in G.
+      34             :     // input/output:
+      35             :     LAGraph_Graph G,        // graph to examine; cached properties computed.
+      36             :     char *msg
+      37             : )
+      38             : {
+      39             :     // find out if graph is symmetric, compute G->out_degree, and G->nself_edges
+      40         404 :     LG_TRY (LAGraph_Cached_IsSymmetricStructure (G, msg)) ;
+      41         404 :     LG_TRY (LAGraph_Cached_OutDegree (G, msg)) ;
+      42         344 :     LG_TRY (LAGraph_Cached_NSelfEdges (G, msg)) ;
+      43             : 
+      44             :     // auto method and auto sort
+      45         344 :     return (LAGr_TriangleCount (ntriangles, G, NULL, NULL, msg)) ;
+      46             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/algorithm/LG_BreadthFirstSearch_SSGrB.c.func-sort-c.html b/src/algorithm/LG_BreadthFirstSearch_SSGrB.c.func-sort-c.html new file mode 100644 index 0000000000..bddd37b6b2 --- /dev/null +++ b/src/algorithm/LG_BreadthFirstSearch_SSGrB.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/algorithm/LG_BreadthFirstSearch_SSGrB.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/algorithm - LG_BreadthFirstSearch_SSGrB.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:9090100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_BreadthFirstSearch_SSGrB9462
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/algorithm/LG_BreadthFirstSearch_SSGrB.c.func.html b/src/algorithm/LG_BreadthFirstSearch_SSGrB.c.func.html new file mode 100644 index 0000000000..6a01237390 --- /dev/null +++ b/src/algorithm/LG_BreadthFirstSearch_SSGrB.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/algorithm/LG_BreadthFirstSearch_SSGrB.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/algorithm - LG_BreadthFirstSearch_SSGrB.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:9090100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_BreadthFirstSearch_SSGrB9462
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/algorithm/LG_BreadthFirstSearch_SSGrB.c.gcov.html b/src/algorithm/LG_BreadthFirstSearch_SSGrB.c.gcov.html new file mode 100644 index 0000000000..102635571f --- /dev/null +++ b/src/algorithm/LG_BreadthFirstSearch_SSGrB.c.gcov.html @@ -0,0 +1,374 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/algorithm/LG_BreadthFirstSearch_SSGrB.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/algorithm - LG_BreadthFirstSearch_SSGrB.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:9090100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LG_BreadthFirstSearch_SSGrB:  BFS using Suitesparse extensions
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // This is an Advanced algorithm.  G->AT and G->out_degree are required for
+      19             : // this method to use push-pull optimization.  If not provided, this method
+      20             : // defaults to a push-only algorithm, which can be slower.  This is not
+      21             : // user-callable (see LAGr_BreadthFirstSearch instead).  G->AT and
+      22             : // G->out_degree are not computed if not present.
+      23             : 
+      24             : // References:
+      25             : //
+      26             : // Carl Yang, Aydin Buluc, and John D. Owens. 2018. Implementing Push-Pull
+      27             : // Efficiently in GraphBLAS. In Proceedings of the 47th International
+      28             : // Conference on Parallel Processing (ICPP 2018). ACM, New York, NY, USA,
+      29             : // Article 89, 11 pages. DOI: https://doi.org/10.1145/3225058.3225122
+      30             : //
+      31             : // Scott Beamer, Krste Asanovic and David A. Patterson, The GAP Benchmark
+      32             : // Suite, http://arxiv.org/abs/1508.03619, 2015.  http://gap.cs.berkeley.edu/
+      33             : 
+      34             : // revised by Tim Davis (davis@tamu.edu), Texas A&M University
+      35             : 
+      36             : #define LG_FREE_WORK        \
+      37             : {                           \
+      38             :     GrB_free (&w) ;         \
+      39             :     GrB_free (&q) ;         \
+      40             : }
+      41             : 
+      42             : #define LG_FREE_ALL         \
+      43             : {                           \
+      44             :     LG_FREE_WORK ;          \
+      45             :     GrB_free (&pi) ;        \
+      46             :     GrB_free (&v) ;         \
+      47             : }
+      48             : 
+      49             : #include "LG_internal.h"
+      50             : 
+      51        9462 : int LG_BreadthFirstSearch_SSGrB
+      52             : (
+      53             :     GrB_Vector *level,
+      54             :     GrB_Vector *parent,
+      55             :     const LAGraph_Graph G,
+      56             :     GrB_Index src,
+      57             :     char *msg
+      58             : )
+      59             : {
+      60             : 
+      61             :     //--------------------------------------------------------------------------
+      62             :     // check inputs
+      63             :     //--------------------------------------------------------------------------
+      64             : 
+      65        9462 :     LG_CLEAR_MSG ;
+      66        9462 :     GrB_Vector q = NULL ;           // the current frontier
+      67        9462 :     GrB_Vector w = NULL ;           // to compute work remaining
+      68        9462 :     GrB_Vector pi = NULL ;          // parent vector
+      69        9462 :     GrB_Vector v = NULL ;           // level vector
+      70             : 
+      71             : #if !LAGRAPH_SUITESPARSE
+      72             :     LG_ASSERT (false, GrB_NOT_IMPLEMENTED) ;
+      73             : #else
+      74             : 
+      75        9462 :     bool compute_level  = (level != NULL) ;
+      76        9462 :     bool compute_parent = (parent != NULL) ;
+      77        9462 :     if (compute_level ) (*level ) = NULL ;
+      78        9462 :     if (compute_parent) (*parent) = NULL ;
+      79        9462 :     LG_ASSERT_MSG (compute_level || compute_parent, GrB_NULL_POINTER,
+      80             :         "either level or parent must be non-NULL") ;
+      81             : 
+      82        9459 :     LG_TRY (LAGraph_CheckGraph (G, msg)) ;
+      83             : 
+      84             :     //--------------------------------------------------------------------------
+      85             :     // get the problem size and cached properties
+      86             :     //--------------------------------------------------------------------------
+      87             : 
+      88        9459 :     GrB_Matrix A = G->A ;
+      89             : 
+      90             :     GrB_Index n, nvals ;
+      91        9459 :     GRB_TRY (GrB_Matrix_nrows (&n, A)) ;
+      92        9459 :     LG_ASSERT_MSG (src < n, GrB_INVALID_INDEX, "invalid source node") ;
+      93             : 
+      94        9457 :     GRB_TRY (GrB_Matrix_nvals (&nvals, A)) ;
+      95             : 
+      96        9457 :     GrB_Matrix AT = NULL ;
+      97        9457 :     GrB_Vector Degree = G->out_degree ;
+      98        9457 :     if (G->kind == LAGraph_ADJACENCY_UNDIRECTED ||
+      99        5478 :        (G->kind == LAGraph_ADJACENCY_DIRECTED &&
+     100        5478 :         G->is_symmetric_structure == LAGraph_TRUE))
+     101             :     {
+     102             :         // AT and A have the same structure and can be used in both directions
+     103        3979 :         AT = G->A ;
+     104             :     }
+     105             :     else
+     106             :     {
+     107             :         // AT = A' is different from A.  If G->AT is NULL, then a push-only
+     108             :         // method is used.
+     109        5478 :         AT = G->AT ;
+     110             :     }
+     111             : 
+     112             :     // direction-optimization requires G->AT (if G is directed) and
+     113             :     // G->out_degree (for both undirected and directed cases)
+     114        9457 :     bool push_pull = (Degree != NULL && AT != NULL) ;
+     115             : 
+     116             :     // determine the semiring type
+     117        9457 :     GrB_Type int_type = (n > INT32_MAX) ? GrB_INT64 : GrB_INT32 ;
+     118             :     GrB_Semiring semiring ;
+     119             : 
+     120        9457 :     if (compute_parent)
+     121             :     {
+     122             :         // use the ANY_SECONDI_INT* semiring: either 32 or 64-bit depending on
+     123             :         // the # of nodes in the graph.
+     124       10562 :         semiring = (n > INT32_MAX) ?
+     125        5281 :             GxB_ANY_SECONDI_INT64 : GxB_ANY_SECONDI_INT32 ;
+     126             : 
+     127             :         // create the parent vector.  pi(i) is the parent id of node i
+     128        5281 :         GRB_TRY (GrB_Vector_new (&pi, int_type, n)) ;
+     129        5033 :         GRB_TRY (GxB_set (pi, GxB_SPARSITY_CONTROL, GxB_BITMAP + GxB_FULL)) ;
+     130             :         // pi (src) = src denotes the root of the BFS tree
+     131        4785 :         GRB_TRY (GrB_Vector_setElement (pi, src, src)) ;
+     132             : 
+     133             :         // create a sparse integer vector q, and set q(src) = src
+     134        4661 :         GRB_TRY (GrB_Vector_new (&q, int_type, n)) ;
+     135        4413 :         GRB_TRY (GrB_Vector_setElement (q, src, src)) ;
+     136             :     }
+     137             :     else
+     138             :     {
+     139             :         // only the level is needed, use the LAGraph_any_one_bool semiring
+     140        4176 :         semiring = LAGraph_any_one_bool ;
+     141             : 
+     142             :         // create a sparse boolean vector q, and set q(src) = true
+     143        4176 :         GRB_TRY (GrB_Vector_new (&q, GrB_BOOL, n)) ;
+     144        3928 :         GRB_TRY (GrB_Vector_setElement (q, true, src)) ;
+     145             :     }
+     146             : 
+     147        7597 :     if (compute_level)
+     148             :     {
+     149             :         // create the level vector. v(i) is the level of node i
+     150             :         // v (src) = 0 denotes the source node
+     151        7417 :         GRB_TRY (GrB_Vector_new (&v, int_type, n)) ;
+     152        6921 :         GRB_TRY (GxB_set (v, GxB_SPARSITY_CONTROL, GxB_BITMAP + GxB_FULL)) ;
+     153        6425 :         GRB_TRY (GrB_Vector_setElement (v, 0, src)) ;
+     154             :     }
+     155             : 
+     156             :     // workspace for computing work remaining
+     157        6357 :     GRB_TRY (GrB_Vector_new (&w, GrB_INT64, n)) ;
+     158             : 
+     159        5861 :     GrB_Index nq = 1 ;          // number of nodes in the current level
+     160        5861 :     double alpha = 8.0 ;
+     161        5861 :     double beta1 = 8.0 ;
+     162        5861 :     double beta2 = 512.0 ;
+     163        5861 :     int64_t n_over_beta1 = (int64_t) (((double) n) / beta1) ;
+     164        5861 :     int64_t n_over_beta2 = (int64_t) (((double) n) / beta2) ;
+     165             : 
+     166             :     //--------------------------------------------------------------------------
+     167             :     // BFS traversal and label the nodes
+     168             :     //--------------------------------------------------------------------------
+     169             : 
+     170        5861 :     bool do_push = true ;       // start with push
+     171        5861 :     GrB_Index last_nq = 0 ;
+     172        5861 :     int64_t edges_unexplored = nvals ;
+     173        5861 :     bool any_pull = false ;     // true if any pull phase has been done
+     174             : 
+     175             :     // {!mask} is the set of unvisited nodes
+     176        5861 :     GrB_Vector mask = (compute_parent) ? pi : v ;
+     177             : 
+     178       36082 :     for (int64_t nvisited = 1, k = 1 ; nvisited < n ; nvisited += nq, k++)
+     179             :     {
+     180             : 
+     181             :         //----------------------------------------------------------------------
+     182             :         // select push vs pull
+     183             :         //----------------------------------------------------------------------
+     184             : 
+     185       35524 :         if (push_pull)
+     186             :         {
+     187       16599 :             if (do_push)
+     188             :             {
+     189             :                 // check for switch from push to pull
+     190       15441 :                 bool growing = nq > last_nq ;
+     191       15441 :                 bool switch_to_pull = false ;
+     192       15441 :                 if (edges_unexplored < n)
+     193             :                 {
+     194             :                     // very little of the graph is left; disable the pull
+     195          28 :                     push_pull = false ;
+     196             :                 }
+     197       15413 :                 else if (any_pull)
+     198             :                 {
+     199             :                     // once any pull phase has been done, the # of edges in the
+     200             :                     // frontier has no longer been tracked.  But now the BFS
+     201             :                     // has switched back to push, and we're checking for yet
+     202             :                     // another switch to pull.  This switch is unlikely, so
+     203             :                     // just keep track of the size of the frontier, and switch
+     204             :                     // if it starts growing again and is getting big.
+     205        9003 :                     switch_to_pull = (growing && nq > n_over_beta1) ;
+     206             :                 }
+     207             :                 else
+     208             :                 {
+     209             :                     // update the # of unexplored edges
+     210             :                     // w<q>=Degree
+     211             :                     // w(i) = outdegree of node i if node i is in the queue
+     212        6410 :                     GRB_TRY (GrB_assign (w, q, NULL, Degree, GrB_ALL, n,
+     213             :                         GrB_DESC_RS)) ;
+     214             :                     // edges_in_frontier = sum (w) = # of edges incident on all
+     215             :                     // nodes in the current frontier
+     216        5286 :                     int64_t edges_in_frontier = 0 ;
+     217        5286 :                     GRB_TRY (GrB_reduce (&edges_in_frontier, NULL,
+     218             :                         GrB_PLUS_MONOID_INT64, w, NULL)) ;
+     219        5286 :                     edges_unexplored -= edges_in_frontier ;
+     220        8296 :                     switch_to_pull = growing &&
+     221        3010 :                         (edges_in_frontier > (edges_unexplored / alpha)) ;
+     222             :                 }
+     223       14317 :                 if (switch_to_pull)
+     224             :                 {
+     225             :                     // switch from push to pull
+     226        1049 :                     do_push = false ;
+     227             :                 }
+     228             :             }
+     229             :             else
+     230             :             {
+     231             :                 // check for switch from pull to push
+     232        1158 :                 bool shrinking = nq < last_nq ;
+     233        1158 :                 if (shrinking && (nq <= n_over_beta2))
+     234             :                 {
+     235             :                     // switch from pull to push
+     236           9 :                     do_push = true ;
+     237             :                 }
+     238             :             }
+     239       15475 :             any_pull = any_pull || (!do_push) ;
+     240             :         }
+     241             : 
+     242             :         //----------------------------------------------------------------------
+     243             :         // q = kth level of the BFS
+     244             :         //----------------------------------------------------------------------
+     245             : 
+     246       34400 :         int sparsity = do_push ? GxB_SPARSE : GxB_BITMAP ;
+     247       34400 :         GRB_TRY (GxB_set (q, GxB_SPARSITY_CONTROL, sparsity)) ;
+     248             : 
+     249             :         // mask is pi if computing parent, v if computing just level
+     250       34234 :         if (do_push)
+     251             :         {
+     252             :             // push (saxpy-based vxm):  q'{!mask} = q'*A
+     253       32102 :             GRB_TRY (GrB_vxm (q, mask, NULL, semiring, q, A, GrB_DESC_RSC)) ;
+     254             :         }
+     255             :         else
+     256             :         {
+     257             :             // pull (dot-product-based mxv):  q{!mask} = AT*q
+     258        2132 :             GRB_TRY (GrB_mxv (q, mask, NULL, semiring, AT, q, GrB_DESC_RSC)) ;
+     259             :         }
+     260             : 
+     261             :         //----------------------------------------------------------------------
+     262             :         // done if q is empty
+     263             :         //----------------------------------------------------------------------
+     264             : 
+     265       30790 :         last_nq = nq ;
+     266       30790 :         GRB_TRY (GrB_Vector_nvals (&nq, q)) ;
+     267       30790 :         if (nq == 0)
+     268             :         {
+     269         230 :             break ;
+     270             :         }
+     271             : 
+     272             :         //----------------------------------------------------------------------
+     273             :         // assign parents/levels
+     274             :         //----------------------------------------------------------------------
+     275             : 
+     276       30560 :         if (compute_parent)
+     277             :         {
+     278             :             // q(i) currently contains the parent id of node i in tree.
+     279             :             // pi{q} = q
+     280       19824 :             GRB_TRY (GrB_assign (pi, q, NULL, q, GrB_ALL, n, GrB_DESC_S)) ;
+     281             :         }
+     282       30453 :         if (compute_level)
+     283             :         {
+     284             :             // v{q} = k, the kth level of the BFS
+     285       21666 :             GRB_TRY (GrB_assign (v, q, NULL, k, GrB_ALL, n, GrB_DESC_S)) ;
+     286             :         }
+     287             :     }
+     288             : 
+     289             :     //--------------------------------------------------------------------------
+     290             :     // free workspace and return result
+     291             :     //--------------------------------------------------------------------------
+     292             : 
+     293         788 :     if (compute_parent) (*parent) = pi ;
+     294         788 :     if (compute_level ) (*level ) = v ;
+     295         788 :     LG_FREE_WORK ;
+     296         788 :     return (GrB_SUCCESS) ;
+     297             : #endif
+     298             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/algorithm/LG_BreadthFirstSearch_vanilla.c.func-sort-c.html b/src/algorithm/LG_BreadthFirstSearch_vanilla.c.func-sort-c.html new file mode 100644 index 0000000000..da55ea1f55 --- /dev/null +++ b/src/algorithm/LG_BreadthFirstSearch_vanilla.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/algorithm/LG_BreadthFirstSearch_vanilla.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/algorithm - LG_BreadthFirstSearch_vanilla.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:4848100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_BreadthFirstSearch_vanilla9464
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/algorithm/LG_BreadthFirstSearch_vanilla.c.func.html b/src/algorithm/LG_BreadthFirstSearch_vanilla.c.func.html new file mode 100644 index 0000000000..2546ec9373 --- /dev/null +++ b/src/algorithm/LG_BreadthFirstSearch_vanilla.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/algorithm/LG_BreadthFirstSearch_vanilla.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/algorithm - LG_BreadthFirstSearch_vanilla.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:4848100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_BreadthFirstSearch_vanilla9464
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/algorithm/LG_BreadthFirstSearch_vanilla.c.gcov.html b/src/algorithm/LG_BreadthFirstSearch_vanilla.c.gcov.html new file mode 100644 index 0000000000..e06f3bb81f --- /dev/null +++ b/src/algorithm/LG_BreadthFirstSearch_vanilla.c.gcov.html @@ -0,0 +1,241 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/algorithm/LG_BreadthFirstSearch_vanilla.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/algorithm - LG_BreadthFirstSearch_vanilla.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:4848100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LG_BreadthFirstSearch_vanilla:  BFS using only GraphBLAS API
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Scott McMillan, derived from examples in the appendix of
+      15             : // The GraphBLAS C API Specification, v1.3.0
+      16             : 
+      17             : //------------------------------------------------------------------------------
+      18             : 
+      19             : // This is a Basic algorithm (no extra cached properties are required),
+      20             : // but it is not user-callable (see LAGr_BreadthFirstSearch instead).
+      21             : 
+      22             : #define LG_FREE_WORK        \
+      23             : {                           \
+      24             :     GrB_free (&frontier);   \
+      25             : }
+      26             : 
+      27             : #define LG_FREE_ALL         \
+      28             : {                           \
+      29             :     LG_FREE_WORK ;          \
+      30             :     GrB_free (&l_parent);   \
+      31             :     GrB_free (&l_level);    \
+      32             : }
+      33             : 
+      34             : #include "LG_internal.h"
+      35             : 
+      36        9464 : int LG_BreadthFirstSearch_vanilla
+      37             : (
+      38             :     GrB_Vector    *level,
+      39             :     GrB_Vector    *parent,
+      40             :     const LAGraph_Graph G,
+      41             :     GrB_Index      src,
+      42             :     char          *msg
+      43             : )
+      44             : {
+      45             : 
+      46             :     //--------------------------------------------------------------------------
+      47             :     // check inputs
+      48             :     //--------------------------------------------------------------------------
+      49             : 
+      50        9464 :     LG_CLEAR_MSG ;
+      51        9464 :     GrB_Vector frontier = NULL;     // the current frontier
+      52        9464 :     GrB_Vector l_parent = NULL;     // parent vector
+      53        9464 :     GrB_Vector l_level = NULL;      // level vector
+      54             : 
+      55        9464 :     bool compute_level  = (level != NULL);
+      56        9464 :     bool compute_parent = (parent != NULL);
+      57        9464 :     if (compute_level ) (*level ) = NULL;
+      58        9464 :     if (compute_parent) (*parent) = NULL;
+      59        9464 :     LG_ASSERT_MSG (compute_level || compute_parent, GrB_NULL_POINTER,
+      60             :         "either level or parent must be non-NULL") ;
+      61             : 
+      62        9461 :     LG_TRY (LAGraph_CheckGraph (G, msg)) ;
+      63             : 
+      64             :     //--------------------------------------------------------------------------
+      65             :     // get the problem size
+      66             :     //--------------------------------------------------------------------------
+      67             : 
+      68        9461 :     GrB_Matrix A = G->A ;
+      69             : 
+      70             :     GrB_Index n;
+      71        9461 :     GRB_TRY( GrB_Matrix_nrows (&n, A) );
+      72        9461 :     LG_ASSERT_MSG (src < n, GrB_INVALID_INDEX, "invalid source node") ;
+      73             : 
+      74             :     // determine the semiring type
+      75        9459 :     GrB_Type     int_type  = (n > INT32_MAX) ? GrB_INT64 : GrB_INT32 ;
+      76             :     GrB_BinaryOp
+      77        9459 :         second_op = (n > INT32_MAX) ? GrB_SECOND_INT64 : GrB_SECOND_INT32 ;
+      78        9459 :     GrB_Semiring semiring  = NULL;
+      79        9459 :     GrB_IndexUnaryOp ramp = NULL ;
+      80             : 
+      81        9459 :     if (compute_parent)
+      82             :     {
+      83             :         // create the parent vector.  l_parent(i) is the parent id of node i
+      84        5338 :         GRB_TRY (GrB_Vector_new(&l_parent, int_type, n)) ;
+      85             : 
+      86       10180 :         semiring = (n > INT32_MAX) ?
+      87        5090 :             GrB_MIN_FIRST_SEMIRING_INT64 : GrB_MIN_FIRST_SEMIRING_INT32;
+      88             : 
+      89             :         // create a sparse integer vector frontier, and set frontier(src) = src
+      90        5090 :         GRB_TRY (GrB_Vector_new(&frontier, int_type, n)) ;
+      91        4842 :         GRB_TRY (GrB_Vector_setElement(frontier, src, src)) ;
+      92             : 
+      93             :         // pick the ramp operator
+      94        4470 :         ramp = (n > INT32_MAX) ? GrB_ROWINDEX_INT64 : GrB_ROWINDEX_INT32 ;
+      95             :     }
+      96             :     else
+      97             :     {
+      98             :         // only the level is needed
+      99        4121 :         semiring = LAGraph_any_one_bool ;
+     100             : 
+     101             :         // create a sparse boolean vector frontier, and set frontier(src) = true
+     102        4121 :         GRB_TRY (GrB_Vector_new(&frontier, GrB_BOOL, n)) ;
+     103        3873 :         GRB_TRY (GrB_Vector_setElement(frontier, true, src)) ;
+     104             :     }
+     105             : 
+     106        7971 :     if (compute_level)
+     107             :     {
+     108             :         // create the level vector. v(i) is the level of node i
+     109             :         // v (src) = 0 denotes the source node
+     110        7791 :         GRB_TRY (GrB_Vector_new(&l_level, int_type, n)) ;
+     111             :     }
+     112             : 
+     113             :     //--------------------------------------------------------------------------
+     114             :     // BFS traversal and label the nodes
+     115             :     //--------------------------------------------------------------------------
+     116             : 
+     117        7475 :     GrB_Index nq = 1 ;          // number of nodes in the current level
+     118        7475 :     GrB_Index last_nq = 0 ;
+     119        7475 :     GrB_Index current_level = 0;
+     120        7475 :     GrB_Index nvals = 1;
+     121             : 
+     122             :     // {!mask} is the set of unvisited nodes
+     123        7475 :     GrB_Vector mask = (compute_parent) ? l_parent : l_level ;
+     124             : 
+     125             :     // parent BFS
+     126             :     do
+     127             :     {
+     128       39395 :         if (compute_level)
+     129             :         {
+     130             :             // assign levels: l_level<s(frontier)> = current_level
+     131       30428 :             GRB_TRY( GrB_assign(l_level, frontier, GrB_NULL,
+     132             :                                 current_level, GrB_ALL, n, GrB_DESC_S) );
+     133       28066 :             ++current_level;
+     134             :         }
+     135             : 
+     136       37033 :         if (compute_parent)
+     137             :         {
+     138             :             // frontier(i) currently contains the parent id of node i in tree.
+     139             :             // l_parent<s(frontier)> = frontier
+     140       23561 :             GRB_TRY( GrB_assign(l_parent, frontier, GrB_NULL,
+     141             :                                 frontier, GrB_ALL, n, GrB_DESC_S) );
+     142             : 
+     143             :             // convert all stored values in frontier to their indices
+     144       23005 :             GRB_TRY (GrB_apply (frontier, GrB_NULL, GrB_NULL, ramp,
+     145             :                 frontier, 0, GrB_NULL)) ;
+     146             :         }
+     147             : 
+     148             :         // frontier = kth level of the BFS
+     149             :         // mask is l_parent if computing parent, l_level if computing just level
+     150       36353 :         GRB_TRY( GrB_vxm(frontier, mask, GrB_NULL, semiring,
+     151             :                          frontier, A, GrB_DESC_RSC) );
+     152             : 
+     153             :         // done if frontier is empty
+     154       32671 :         GRB_TRY( GrB_Vector_nvals(&nvals, frontier) );
+     155       32671 :     } while (nvals > 0);
+     156             : 
+     157             :     //--------------------------------------------------------------------------
+     158             :     // free workspace and return result
+     159             :     //--------------------------------------------------------------------------
+     160             : 
+     161         751 :     if (compute_parent) (*parent) = l_parent ;
+     162         751 :     if (compute_level ) (*level ) = l_level ;
+     163         751 :     LG_FREE_WORK ;
+     164         751 :     return (GrB_SUCCESS) ;
+     165             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/algorithm/LG_CC_Boruvka.c.func-sort-c.html b/src/algorithm/LG_CC_Boruvka.c.func-sort-c.html new file mode 100644 index 0000000000..ea93a0f84a --- /dev/null +++ b/src/algorithm/LG_CC_Boruvka.c.func-sort-c.html @@ -0,0 +1,84 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/algorithm/LG_CC_Boruvka.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/algorithm - LG_CC_Boruvka.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:6969100.0 %
Date:2024-08-29 20:08:04Functions:33100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
Reduce_assign40
LG_CC_Boruvka50
my_select_func506860
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/algorithm/LG_CC_Boruvka.c.func.html b/src/algorithm/LG_CC_Boruvka.c.func.html new file mode 100644 index 0000000000..cb7bfbe259 --- /dev/null +++ b/src/algorithm/LG_CC_Boruvka.c.func.html @@ -0,0 +1,84 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/algorithm/LG_CC_Boruvka.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/algorithm - LG_CC_Boruvka.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:6969100.0 %
Date:2024-08-29 20:08:04Functions:33100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_CC_Boruvka50
Reduce_assign40
my_select_func506860
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/algorithm/LG_CC_Boruvka.c.gcov.html b/src/algorithm/LG_CC_Boruvka.c.gcov.html new file mode 100644 index 0000000000..8a157f2c49 --- /dev/null +++ b/src/algorithm/LG_CC_Boruvka.c.gcov.html @@ -0,0 +1,356 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/algorithm/LG_CC_Boruvka.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/algorithm - LG_CC_Boruvka.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:6969100.0 %
Date:2024-08-29 20:08:04Functions:33100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LG_CC_Boruvka.c:  connected components using GrB* methods only
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Yongzhe Zhang (zyz915@gmail.com).
+      15             : // Modified by Timothy A. Davis, Texas A&M University
+      16             : 
+      17             : //------------------------------------------------------------------------------
+      18             : 
+      19             : // This is an Advanced algorithm (G->is_symmetric_structure must be known),
+      20             : // but it is not user-callable (see LAGr_ConnectedComponents instead).
+      21             : 
+      22             : // Code is based on Boruvka's minimum spanning forest algorithm.
+      23             : 
+      24             : // This method relies solely on GrB* methods in the V2.0 C API, but it much
+      25             : // slower in general than LG_CC_FastSV6, which uses GxB pack/unpack methods
+      26             : // for faster access to the contents of the matrices and vectors.
+      27             : 
+      28             : #include <stdint.h>
+      29             : 
+      30             : #include "LG_internal.h"
+      31             : 
+      32             : //------------------------------------------------------------------------------
+      33             : // Reduce_assign
+      34             : //------------------------------------------------------------------------------
+      35             : 
+      36             : // w[Px[i]] = min(w[Px[i]], s[i]) for i in [0..n-1].
+      37             : 
+      38          40 : static GrB_Info Reduce_assign
+      39             : (
+      40             :     GrB_Vector w,       // input/output vector of size n
+      41             :     GrB_Vector s,       // input vector of size n
+      42             :     GrB_Index *Px,      // Px: array of size n
+      43             :     GrB_Index *mem,     // workspace of size 3*n
+      44             :     GrB_Index n
+      45             : )
+      46             : {
+      47          40 :     char *msg = NULL ;
+      48          40 :     GrB_Index *ind  = mem ;
+      49          40 :     GrB_Index *sval = ind + n ;
+      50          40 :     GrB_Index *wval = sval + n ;
+      51          40 :     GRB_TRY (GrB_Vector_extractTuples (ind, wval, &n, w)) ;
+      52          40 :     GRB_TRY (GrB_Vector_extractTuples (ind, sval, &n, s)) ;
+      53       34190 :     for (GrB_Index j = 0 ; j < n ; j++)
+      54             :     {
+      55       34150 :         if (sval [j] < wval [Px [j]])
+      56             :         {
+      57       12526 :             wval [Px [j]] = sval [j] ;
+      58             :         }
+      59             :     }
+      60          40 :     GRB_TRY (GrB_Vector_clear (w)) ;
+      61          40 :     GRB_TRY (GrB_Vector_build (w, ind, wval, n, GrB_PLUS_UINT64)) ;
+      62             :     LG_FREE_ALL ;
+      63          40 :     return (GrB_SUCCESS) ;
+      64             : }
+      65             : 
+      66             : //------------------------------------------------------------------------------
+      67             : // select_func: IndexUnaryOp for pruning entries from S
+      68             : //------------------------------------------------------------------------------
+      69             : 
+      70             : // The pointer to the Px array is passed to the select function as a component
+      71             : // of a user-defined data type.
+      72             : 
+      73             : typedef struct
+      74             : {
+      75             :     GrB_Index *pointer ;
+      76             : }
+      77             : Parent_struct ;
+      78             : 
+      79      506860 : void my_select_func (void *z, const void *x,
+      80             :                  const GrB_Index i, const GrB_Index j, const void *y)
+      81             : {
+      82      506860 :     Parent_struct *Parent = (Parent_struct *) y ;
+      83      506860 :     GrB_Index *Px = Parent->pointer ;
+      84      506860 :     (*((bool *) z)) = (Px [i] != Px [j]) ;
+      85      506860 : }
+      86             : 
+      87             : //------------------------------------------------------------------------------
+      88             : // LG_CC_Boruvka
+      89             : //------------------------------------------------------------------------------
+      90             : 
+      91             : #undef  LG_FREE_ALL
+      92             : #define LG_FREE_ALL                         \
+      93             : {                                           \
+      94             :     LG_FREE_WORK ;                          \
+      95             :     GrB_free (&parent) ;                    \
+      96             : }
+      97             : 
+      98             : #undef  LG_FREE_WORK
+      99             : #define LG_FREE_WORK                        \
+     100             : {                                           \
+     101             :     LAGraph_Free ((void **) &I, NULL) ;     \
+     102             :     LAGraph_Free ((void **) &Px, NULL) ;    \
+     103             :     LAGraph_Free ((void **) &mem, NULL) ;   \
+     104             :     GrB_free (&S) ;                         \
+     105             :     GrB_free (&Parent_Type) ;               \
+     106             :     GrB_free (&gp) ;                        \
+     107             :     GrB_free (&mnp) ;                       \
+     108             :     GrB_free (&ccmn) ;                      \
+     109             :     GrB_free (&ramp) ;                      \
+     110             :     GrB_free (&mask) ;                      \
+     111             :     GrB_free (&select_op) ;                 \
+     112             : }
+     113             : 
+     114          50 : int LG_CC_Boruvka
+     115             : (
+     116             :     // output:
+     117             :     GrB_Vector *component,  // output: array of component identifiers
+     118             :     // input:
+     119             :     const LAGraph_Graph G,  // input graph, not modified
+     120             :     char *msg
+     121             : )
+     122             : {
+     123             : 
+     124             :     //--------------------------------------------------------------------------
+     125             :     // check inputs
+     126             :     //--------------------------------------------------------------------------
+     127             : 
+     128          50 :     GrB_Index n, *I = NULL, *Px = NULL, *mem = NULL ;
+     129          50 :     GrB_Vector parent = NULL, gp = NULL, mnp = NULL, ccmn = NULL, ramp = NULL,
+     130          50 :         mask = NULL ;
+     131          50 :     GrB_IndexUnaryOp select_op = NULL ;
+     132          50 :     GrB_Matrix S = NULL ;
+     133          50 :     GrB_Type Parent_Type = NULL ;
+     134             :     Parent_struct Parent ;
+     135             : 
+     136          50 :     LG_CLEAR_MSG ;
+     137          50 :     LG_TRY (LAGraph_CheckGraph (G, msg)) ;
+     138          49 :     LG_ASSERT (component != NULL, GrB_NULL_POINTER) ;
+     139             : 
+     140          25 :     LG_ASSERT_MSG ((G->kind == LAGraph_ADJACENCY_UNDIRECTED ||
+     141             :        (G->kind == LAGraph_ADJACENCY_DIRECTED &&
+     142             :         G->is_symmetric_structure == LAGraph_TRUE)),
+     143             :         LAGRAPH_SYMMETRIC_STRUCTURE_REQUIRED,
+     144             :         "G->A must be known to be symmetric") ;
+     145             : 
+     146             :     //--------------------------------------------------------------------------
+     147             :     // initializations
+     148             :     //--------------------------------------------------------------------------
+     149             : 
+     150             :     // S = structure of G->A
+     151          24 :     LG_TRY (LAGraph_Matrix_Structure (&S, G->A, msg)) ;
+     152             : 
+     153          24 :     GRB_TRY (GrB_Matrix_nrows (&n, S)) ;
+     154          24 :     GRB_TRY (GrB_Vector_new (&parent, GrB_UINT64, n)) ; // final result
+     155          24 :     GRB_TRY (GrB_Vector_new (&gp, GrB_UINT64, n)) ;     // grandparents
+     156          24 :     GRB_TRY (GrB_Vector_new (&mnp, GrB_UINT64, n)) ;    // min neighbor parent
+     157          24 :     GRB_TRY (GrB_Vector_new (&ccmn, GrB_UINT64, n)) ;   // cc's min neighbor
+     158          24 :     GRB_TRY (GrB_Vector_new (&mask, GrB_BOOL, n)) ;     // various uses
+     159             : 
+     160          24 :     LG_TRY (LAGraph_Malloc ((void **) &mem, 3*n, sizeof (GrB_Index), msg)) ;
+     161          24 :     LG_TRY (LAGraph_Malloc ((void **) &Px, n, sizeof (GrB_Index), msg)) ;
+     162          24 :     Parent.pointer = Px ;
+     163             : 
+     164          24 :     GRB_TRY (GrB_Type_new (&Parent_Type, sizeof (Parent_struct))) ;
+     165             : 
+     166             :     #if !LAGRAPH_SUITESPARSE
+     167             :     // I is not needed for SuiteSparse and remains NULL
+     168             :     LG_TRY (LAGraph_Malloc ((void **) &I, n, sizeof (GrB_Index), msg)) ;
+     169             :     #endif
+     170             : 
+     171             :     // parent = 0:n-1, and copy to ramp
+     172          24 :     GRB_TRY (GrB_assign (parent, NULL, NULL, 0, GrB_ALL, n, NULL)) ;
+     173          24 :     GRB_TRY (GrB_apply  (parent, NULL, NULL, GrB_ROWINDEX_INT64, parent, 0,
+     174             :         NULL)) ;
+     175          24 :     GRB_TRY (GrB_Vector_dup (&ramp, parent)) ;
+     176             : 
+     177             :     // Px is a non-opaque copy of the parent GrB_Vector
+     178          24 :     GRB_TRY (GrB_Vector_extractTuples (I, Px, &n, parent)) ;
+     179             : 
+     180          24 :     GRB_TRY (GrB_IndexUnaryOp_new (&select_op, my_select_func, GrB_BOOL,
+     181             :         /* aij: ignored */ GrB_BOOL, /* y: pointer to Px */ Parent_Type)) ;
+     182             : 
+     183             :     GrB_Index nvals ;
+     184          24 :     GRB_TRY (GrB_Matrix_nvals (&nvals, S)) ;
+     185             : 
+     186             :     //--------------------------------------------------------------------------
+     187             :     // find the connected components
+     188             :     //--------------------------------------------------------------------------
+     189             : 
+     190          64 :     while (nvals > 0)
+     191             :     {
+     192             : 
+     193             :         //----------------------------------------------------------------------
+     194             :         // mnp[u] = u's minimum neighbor's parent for all nodes u
+     195             :         //----------------------------------------------------------------------
+     196             : 
+     197             :         // every vertex points to a root vertex at the begining
+     198          40 :         GRB_TRY (GrB_assign (mnp, NULL, NULL, n, GrB_ALL, n, NULL)) ;
+     199          40 :         GRB_TRY (GrB_mxv (mnp, NULL, GrB_MIN_UINT64,
+     200             :                     GrB_MIN_SECOND_SEMIRING_UINT64, S, parent, NULL)) ;
+     201             : 
+     202             :         //----------------------------------------------------------------------
+     203             :         // find the minimum neighbor
+     204             :         //----------------------------------------------------------------------
+     205             : 
+     206             :         // ccmn[u] = connect component's minimum neighbor | if u is a root
+     207             :         //         = n                                    | otherwise
+     208          40 :         GRB_TRY (GrB_assign (ccmn, NULL, NULL, n, GrB_ALL, n, NULL)) ;
+     209          40 :         GRB_TRY (Reduce_assign (ccmn, mnp, Px, mem, n)) ;
+     210             : 
+     211             :         //----------------------------------------------------------------------
+     212             :         // parent[u] = ccmn[u] if ccmn[u] != n
+     213             :         //----------------------------------------------------------------------
+     214             : 
+     215             :         // mask = (ccnm != n)
+     216          40 :         GRB_TRY (GrB_apply (mask, NULL, NULL, GrB_NE_UINT64, ccmn, n, NULL)) ;
+     217             :         // parent<mask> = ccmn
+     218          40 :         GRB_TRY (GrB_assign (parent, mask, NULL, ccmn, GrB_ALL, n, NULL)) ;
+     219             : 
+     220             :         //----------------------------------------------------------------------
+     221             :         // select new roots
+     222             :         //----------------------------------------------------------------------
+     223             : 
+     224             :         // identify all pairs (u,v) where parent [u] == v and parent [v] == u
+     225             :         // and then select the minimum of u, v as the new root;
+     226             :         // if (parent [parent [i]] == i) parent [i] = min (parent [i], i)
+     227             : 
+     228             :         // compute grandparents: gp = parent (parent)
+     229          40 :         GRB_TRY (GrB_Vector_extractTuples (I, Px, &n, parent)) ;
+     230          40 :         GRB_TRY (GrB_extract (gp, NULL, NULL, parent, Px, n, NULL)) ;
+     231             : 
+     232             :         // mask = (gp == 0:n-1)
+     233          40 :         GRB_TRY (GrB_eWiseMult (mask, NULL, NULL, GrB_EQ_UINT64, gp, ramp,
+     234             :             NULL)) ;
+     235             :         // parent<mask> = min (parent, ramp)
+     236          40 :         GRB_TRY (GrB_assign (parent, mask, GrB_MIN_UINT64, ramp, GrB_ALL, n,
+     237             :             NULL)) ;
+     238             : 
+     239             :         //----------------------------------------------------------------------
+     240             :         // shortcutting: parent [i] = parent [parent [i]] until convergence
+     241             :         //----------------------------------------------------------------------
+     242             : 
+     243          40 :         bool changing = true ;
+     244             :         while (true)
+     245             :         {
+     246             :             // compute grandparents: gp = parent (parent)
+     247         122 :             GRB_TRY (GrB_Vector_extractTuples (I, Px, &n, parent)) ;
+     248         122 :             GRB_TRY (GrB_extract (gp, NULL, NULL, parent, Px, n, NULL)) ;
+     249             : 
+     250             :             // changing = or (parent != gp)
+     251         122 :             GRB_TRY (GrB_eWiseMult (mask, NULL, NULL, GrB_NE_UINT64, parent, gp,
+     252             :                 NULL)) ;
+     253         122 :             GRB_TRY (GrB_reduce (&changing, NULL, GrB_LOR_MONOID_BOOL, mask,
+     254             :                 NULL)) ;
+     255         122 :             if (!changing) break ;
+     256             : 
+     257             :             // parent = gp
+     258          82 :             GRB_TRY (GrB_assign (parent, NULL, NULL, gp, GrB_ALL, n, NULL)) ;
+     259             :         }
+     260             : 
+     261             :         //----------------------------------------------------------------------
+     262             :         // remove the edges inside each connected component
+     263             :         //----------------------------------------------------------------------
+     264             : 
+     265             :         // This step is the costliest part of this algorithm when dealing with
+     266             :         // large matrices.
+     267          40 :         GRB_TRY (GrB_Matrix_select_UDT (S, NULL, NULL, select_op, S,
+     268             :             (void *) (&Parent), NULL)) ;
+     269          40 :         GRB_TRY (GrB_Matrix_nvals (&nvals, S)) ;
+     270             :     }
+     271             : 
+     272             :     //--------------------------------------------------------------------------
+     273             :     // free workspace and return result
+     274             :     //--------------------------------------------------------------------------
+     275             : 
+     276          24 :     (*component) = parent ;
+     277          24 :     LG_FREE_WORK ;
+     278          24 :     return (GrB_SUCCESS) ;
+     279             : }
+     280             : 
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/algorithm/LG_CC_FastSV6.c.func-sort-c.html b/src/algorithm/LG_CC_FastSV6.c.func-sort-c.html new file mode 100644 index 0000000000..2a3c9a0068 --- /dev/null +++ b/src/algorithm/LG_CC_FastSV6.c.func-sort-c.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/algorithm/LG_CC_FastSV6.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/algorithm - LG_CC_FastSV6.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:162162100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
fastsv36
LG_CC_FastSV664
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/algorithm/LG_CC_FastSV6.c.func.html b/src/algorithm/LG_CC_FastSV6.c.func.html new file mode 100644 index 0000000000..9727572f64 --- /dev/null +++ b/src/algorithm/LG_CC_FastSV6.c.func.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/algorithm/LG_CC_FastSV6.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/algorithm - LG_CC_FastSV6.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:162162100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_CC_FastSV664
fastsv36
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/algorithm/LG_CC_FastSV6.c.gcov.html b/src/algorithm/LG_CC_FastSV6.c.gcov.html new file mode 100644 index 0000000000..b656878b5e --- /dev/null +++ b/src/algorithm/LG_CC_FastSV6.c.gcov.html @@ -0,0 +1,747 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/algorithm/LG_CC_FastSV6.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/algorithm - LG_CC_FastSV6.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:162162100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LG_CC_FastSV6: connected components
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Yongzhe Zhang, modified by Timothy A. Davis, Texas A&M
+      15             : // University
+      16             : 
+      17             : //------------------------------------------------------------------------------
+      18             : 
+      19             : // This is an Advanced algorithm (G->is_symmetric_structure must be known),
+      20             : // but it is not user-callable (see LAGr_ConnectedComponents instead).
+      21             : 
+      22             : // Code is based on the algorithm described in the following paper:
+      23             : // Zhang, Azad, Hu. FastSV: A Distributed-Memory Connected Component
+      24             : // Algorithm with Fast Convergence (SIAM PP20)
+      25             : 
+      26             : // A subsequent update to the algorithm is here (which might not be reflected
+      27             : // in this code):
+      28             : // Yongzhe Zhang, Ariful Azad, Aydin Buluc: Parallel algorithms for finding
+      29             : // connected components using linear algebra. J. Parallel Distributed Comput.
+      30             : // 144: 14-27 (2020).
+      31             : 
+      32             : // Modified by Tim Davis, Texas A&M University: revised Reduce_assign to use
+      33             : // purely GrB* and GxB* methods and the matrix C.  Added warmup phase.  Changed
+      34             : // to use GxB pack/unpack instead of GxB import/export.  Converted to use the
+      35             : // LAGraph_Graph object.  Exploiting iso status for the temporary matrices
+      36             : // C and T.
+      37             : 
+      38             : // The input graph G must be undirected, or directed and with an adjacency
+      39             : // matrix that has a symmetric structure.  Self-edges (diagonal entries) are
+      40             : // OK, and are ignored.  The values and type of A are ignored; just its
+      41             : // structure is accessed.
+      42             : 
+      43             : // NOTE: This function must not be called by multiple user threads at the same
+      44             : // time on the same graph G, since it unpacks G->A and then packs it back when
+      45             : // done.  G->A is unchanged when the function returns, but during execution
+      46             : // G->A is empty.  This will be fixed once the todos are finished below, and
+      47             : // G->A will then become a truly read-only object (assuming GrB_wait (G->A)
+      48             : // has been done first).
+      49             : 
+      50             : #define __STDC_WANT_LIB_EXT1__ 1
+      51             : #include <string.h>
+      52             : 
+      53             : #define LG_FREE_ALL ;
+      54             : #include "LG_internal.h"
+      55             : 
+      56             : #if LAGRAPH_SUITESPARSE
+      57             : 
+      58             : //==============================================================================
+      59             : // fastsv: find the components of a graph
+      60             : //==============================================================================
+      61             : 
+      62          36 : static inline GrB_Info fastsv
+      63             : (
+      64             :     GrB_Matrix A,           // adjacency matrix, G->A or a subset of G->A
+      65             :     GrB_Vector parent,      // parent vector
+      66             :     GrB_Vector mngp,        // min neighbor grandparent
+      67             :     GrB_Vector *gp,         // grandparent
+      68             :     GrB_Vector *gp_new,     // new grandparent (swapped with gp)
+      69             :     GrB_Vector t,           // workspace
+      70             :     GrB_BinaryOp eq,        // GrB_EQ_(integer type)
+      71             :     GrB_BinaryOp min,       // GrB_MIN_(integer type)
+      72             :     GrB_Semiring min_2nd,   // GrB_MIN_SECOND_(integer type)
+      73             :     GrB_Matrix C,           // C(i,j) present if i = Px (j)
+      74             :     GrB_Index **Cp,         // 0:n, size n+1
+      75             :     GrB_Index **Px,         // Px: non-opaque copy of parent vector, size n
+      76             :     void **Cx,              // size 1, contents not accessed
+      77             :     char *msg
+      78             : )
+      79             : {
+      80             :     GrB_Index n ;
+      81          36 :     GRB_TRY (GrB_Vector_size (&n, parent)) ;
+      82          36 :     GrB_Index Cp_size = (n+1) * sizeof (GrB_Index) ;
+      83          36 :     GrB_Index Ci_size = n * sizeof (GrB_Index) ;
+      84          36 :     GrB_Index Cx_size = sizeof (bool) ;
+      85          36 :     bool iso = true, jumbled = false, done = false ;
+      86             : 
+      87             :     while (true)
+      88          53 :     {
+      89             : 
+      90             :         //----------------------------------------------------------------------
+      91             :         // hooking & shortcutting
+      92             :         //----------------------------------------------------------------------
+      93             : 
+      94             :         // mngp = min (mngp, A*gp) using the MIN_SECOND semiring
+      95          89 :         GRB_TRY (GrB_mxv (mngp, NULL, min, min_2nd, A, *gp, NULL)) ;
+      96             : 
+      97             :         //----------------------------------------------------------------------
+      98             :         // parent = min (parent, C*mngp) where C(i,j) is present if i=Px(j)
+      99             :         //----------------------------------------------------------------------
+     100             : 
+     101             :         // Reduce_assign: The Px array of size n is the non-opaque copy of the
+     102             :         // parent vector, where i = Px [j] if the parent of node j is node i.
+     103             :         // It can thus have duplicates.  The vectors parent and mngp are full
+     104             :         // (all entries present).  This function computes the following, which
+     105             :         // is done explicitly in the Reduce_assign function in LG_CC_Boruvka:
+     106             :         //
+     107             :         //      for (j = 0 ; j < n ; j++)
+     108             :         //      {
+     109             :         //          uint64_t i = Px [j] ;
+     110             :         //          parent [i] = min (parent [i], mngp [j]) ;
+     111             :         //      }
+     112             :         //
+     113             :         // If C(i,j) is present where i == Px [j], then this can be written as:
+     114             :         //
+     115             :         //      parent = min (parent, C*mngp)
+     116             :         //
+     117             :         // when using the min_2nd semiring.  This can be done efficiently
+     118             :         // because C can be constructed in O(1) time and O(1) additional space
+     119             :         // (not counting the prior Cp, Px, and Cx arrays), when using the
+     120             :         // SuiteSparse pack/unpack move constructors.  The min_2nd semiring
+     121             :         // ignores the values of C and operates only on the structure, so its
+     122             :         // values are not relevant.  Cx is thus chosen as a GrB_BOOL array of
+     123             :         // size 1 where Cx [0] = false, so the all entries present in C are
+     124             :         // equal to false.
+     125             : 
+     126             :         // pack Cp, Px, and Cx into a matrix C with C(i,j) present if Px(j) == i
+     127          89 :         GRB_TRY (GxB_Matrix_pack_CSC (C, Cp, /* Px is Ci: */ Px, Cx,
+     128             :             Cp_size, Ci_size, Cx_size, iso, jumbled, NULL)) ;
+     129             : 
+     130             :         // parent = min (parent, C*mngp) using the MIN_SECOND semiring
+     131          89 :         GRB_TRY (GrB_mxv (parent, NULL, min, min_2nd, C, mngp, NULL)) ;
+     132             : 
+     133             :         // unpack the contents of C, to make Px available to this method again.
+     134          89 :         GRB_TRY (GxB_Matrix_unpack_CSC (C, Cp, Px, Cx,
+     135             :             &Cp_size, &Ci_size, &Cx_size, &iso, &jumbled, NULL)) ;
+     136             : 
+     137             :         //----------------------------------------------------------------------
+     138             :         // parent = min (parent, mngp, gp)
+     139             :         //----------------------------------------------------------------------
+     140             : 
+     141          85 :         GRB_TRY (GrB_eWiseAdd (parent, NULL, min, min, mngp, *gp, NULL)) ;
+     142             : 
+     143             :         //----------------------------------------------------------------------
+     144             :         // calculate grandparent: gp_new = parent (parent), and extract Px
+     145             :         //----------------------------------------------------------------------
+     146             : 
+     147             :         // if parent is uint32, GraphBLAS typecasts to uint64 for Px.
+     148          85 :         GRB_TRY (GrB_Vector_extractTuples (NULL, *Px, &n, parent)) ;
+     149          85 :         GRB_TRY (GrB_extract (*gp_new, NULL, NULL, parent, *Px, n, NULL)) ;
+     150             : 
+     151             :         //----------------------------------------------------------------------
+     152             :         // terminate if gp and gp_new are the same
+     153             :         //----------------------------------------------------------------------
+     154             : 
+     155          81 :         GRB_TRY (GrB_eWiseMult (t, NULL, NULL, eq, *gp_new, *gp, NULL)) ;
+     156          80 :         GRB_TRY (GrB_reduce (&done, NULL, GrB_LAND_MONOID_BOOL, t, NULL)) ;
+     157          80 :         if (done) break ;
+     158             : 
+     159             :         // swap gp and gp_new
+     160          53 :         GrB_Vector s = (*gp) ; (*gp) = (*gp_new) ; (*gp_new) = s ;
+     161             :     }
+     162          27 :     return (GrB_SUCCESS) ;
+     163             : }
+     164             : 
+     165             : //==============================================================================
+     166             : // LG_CC_FastSV6
+     167             : //==============================================================================
+     168             : 
+     169             : // The output of LG_CC_FastSV* is a vector component, where component(i)=r if
+     170             : // node i is in the connected compononent whose representative is node r.  If r
+     171             : // is a representative, then component(r)=r.  The number of connected
+     172             : // components in the graph G is the number of representatives.
+     173             : 
+     174             : #undef  LG_FREE_WORK
+     175             : #define LG_FREE_WORK                            \
+     176             : {                                               \
+     177             :     LAGraph_Free ((void **) &Tp, NULL) ;        \
+     178             :     LAGraph_Free ((void **) &Tj, NULL) ;        \
+     179             :     LAGraph_Free ((void **) &Tx, NULL) ;        \
+     180             :     LAGraph_Free ((void **) &Cp, NULL) ;        \
+     181             :     LAGraph_Free ((void **) &Px, NULL) ;        \
+     182             :     LAGraph_Free ((void **) &Cx, NULL) ;        \
+     183             :     LAGraph_Free ((void **) &ht_key, NULL) ;    \
+     184             :     LAGraph_Free ((void **) &ht_count, NULL) ;  \
+     185             :     LAGraph_Free ((void **) &count, NULL) ;     \
+     186             :     LAGraph_Free ((void **) &range, NULL) ;     \
+     187             :     GrB_free (&C) ;                             \
+     188             :     GrB_free (&T) ;                             \
+     189             :     GrB_free (&t) ;                             \
+     190             :     GrB_free (&y) ;                             \
+     191             :     GrB_free (&gp) ;                            \
+     192             :     GrB_free (&mngp) ;                          \
+     193             :     GrB_free (&gp_new) ;                        \
+     194             : }
+     195             : 
+     196             : #undef  LG_FREE_ALL
+     197             : #define LG_FREE_ALL                             \
+     198             : {                                               \
+     199             :     LG_FREE_WORK ;                              \
+     200             :     GrB_free (&parent) ;                        \
+     201             : }
+     202             : 
+     203             : #endif
+     204             : 
+     205          64 : int LG_CC_FastSV6           // SuiteSparse:GraphBLAS method, with GxB extensions
+     206             : (
+     207             :     // output:
+     208             :     GrB_Vector *component,  // component(i)=r if node is in the component r
+     209             :     // input:
+     210             :     LAGraph_Graph G,        // input graph (modified then restored)
+     211             :     char *msg
+     212             : )
+     213             : {
+     214             : 
+     215             : #if !LAGRAPH_SUITESPARSE
+     216             :     LG_ASSERT (false, GrB_NOT_IMPLEMENTED) ;
+     217             : #else
+     218             : 
+     219             :     //--------------------------------------------------------------------------
+     220             :     // check inputs
+     221             :     //--------------------------------------------------------------------------
+     222             : 
+     223          64 :     LG_CLEAR_MSG ;
+     224             : 
+     225          64 :     int64_t *range = NULL ;
+     226          64 :     GrB_Index n, nvals, Cp_size = 0, *ht_key = NULL, *Px = NULL, *Cp = NULL,
+     227          64 :         *count = NULL, *Tp = NULL, *Tj = NULL ;
+     228          64 :     GrB_Vector parent = NULL, gp_new = NULL, mngp = NULL, gp = NULL, t = NULL,
+     229          64 :         y = NULL ;
+     230          64 :     GrB_Matrix T = NULL, C = NULL ;
+     231          64 :     void *Tx = NULL, *Cx = NULL ;
+     232          64 :     int *ht_count = NULL ;
+     233             : 
+     234          64 :     LG_TRY (LAGraph_CheckGraph (G, msg)) ;
+     235          63 :     LG_ASSERT (component != NULL, GrB_NULL_POINTER) ;
+     236          63 :     (*component) = NULL ;
+     237             : 
+     238          63 :     LG_ASSERT_MSG ((G->kind == LAGraph_ADJACENCY_UNDIRECTED ||
+     239             :        (G->kind == LAGraph_ADJACENCY_DIRECTED &&
+     240             :         G->is_symmetric_structure == LAGraph_TRUE)),
+     241             :         LAGRAPH_SYMMETRIC_STRUCTURE_REQUIRED,
+     242             :         "G->A must be known to be symmetric") ;
+     243             : 
+     244             :     //--------------------------------------------------------------------------
+     245             :     // initializations
+     246             :     //--------------------------------------------------------------------------
+     247             : 
+     248          62 :     GrB_Matrix A = G->A ;
+     249          62 :     GRB_TRY (GrB_Matrix_nrows (&n, A)) ;
+     250          62 :     GRB_TRY (GrB_Matrix_nvals (&nvals, A)) ;
+     251             : 
+     252             :     // determine the integer type, operators, and semirings to use
+     253             :     GrB_Type Uint, Int ;
+     254             :     GrB_IndexUnaryOp ramp ;
+     255             :     GrB_Semiring min_2nd, min_2ndi ;
+     256             :     GrB_BinaryOp min, eq, imin ;
+     257             :     #ifdef COVERAGE
+     258             :     // Just for test coverage, use 64-bit ints for n > 100.  Do not use this
+     259             :     // rule in production!
+     260             :     #define NBIG 100
+     261             :     #else
+     262             :     // For production use: 64-bit integers if n > 2^31
+     263             :     #define NBIG INT32_MAX
+     264             :     #endif
+     265          62 :     if (n > NBIG)
+     266             :     {
+     267             :         // use 64-bit integers throughout
+     268           8 :         Uint = GrB_UINT64 ;
+     269           8 :         Int  = GrB_INT64  ;
+     270           8 :         ramp = GrB_ROWINDEX_INT64 ;
+     271           8 :         min  = GrB_MIN_UINT64 ;
+     272           8 :         imin = GrB_MIN_INT64 ;
+     273           8 :         eq   = GrB_EQ_UINT64 ;
+     274           8 :         min_2nd  = GrB_MIN_SECOND_SEMIRING_UINT64 ;
+     275           8 :         min_2ndi = GxB_MIN_SECONDI_INT64 ;
+     276             :     }
+     277             :     else
+     278             :     {
+     279             :         // use 32-bit integers, except for Px and for constructing the matrix C
+     280          54 :         Uint = GrB_UINT32 ;
+     281          54 :         Int  = GrB_INT32  ;
+     282          54 :         ramp = GrB_ROWINDEX_INT32 ;
+     283          54 :         min  = GrB_MIN_UINT32 ;
+     284          54 :         imin = GrB_MIN_INT32 ;
+     285          54 :         eq   = GrB_EQ_UINT32 ;
+     286          54 :         min_2nd  = GrB_MIN_SECOND_SEMIRING_UINT32 ;
+     287          54 :         min_2ndi = GxB_MIN_SECONDI_INT32 ;
+     288             :     }
+     289             : 
+     290             :     // FASTSV_SAMPLES: number of samples to take from each row A(i,:).
+     291             :     // Sampling is used if the average degree is > 8 and if n > 1024.
+     292             :     #define FASTSV_SAMPLES 4
+     293          62 :     bool sampling = (nvals > n * FASTSV_SAMPLES * 2 && n > 1024) ;
+     294             : 
+     295             : // [ todo: nthreads will not be needed once GxB_select with a GxB_RankUnaryOp
+     296             : // and a new GxB_extract are added to SuiteSparse:GraphBLAS.
+     297             :     // determine # of threads to use
+     298             :     int nthreads, nthreads_outer, nthreads_inner ;
+     299          62 :     LG_TRY (LAGraph_GetNumThreads (&nthreads_outer, &nthreads_inner, msg)) ;
+     300          62 :     nthreads = nthreads_outer * nthreads_inner ;
+     301          62 :     nthreads = LAGRAPH_MIN (nthreads, n / 16) ;
+     302          62 :     nthreads = LAGRAPH_MAX (nthreads, 1) ;
+     303             : // ]
+     304             : 
+     305          62 :     LG_TRY (LAGraph_Calloc ((void **) &Cx, 1, sizeof (bool), msg)) ;
+     306          61 :     LG_TRY (LAGraph_Malloc ((void **) &Px, n, sizeof (GrB_Index), msg)) ;
+     307             : 
+     308             :     // create Cp = 0:n (always 64-bit) and the empty C matrix
+     309          60 :     GRB_TRY (GrB_Matrix_new (&C, GrB_BOOL, n, n)) ;
+     310          57 :     GRB_TRY (GrB_Vector_new (&t, GrB_INT64, n+1)) ;
+     311          55 :     GRB_TRY (GrB_assign (t, NULL, NULL, 0, GrB_ALL, n+1, NULL)) ;
+     312          54 :     GRB_TRY (GrB_apply (t, NULL, NULL, GrB_ROWINDEX_INT64, t, 0, NULL)) ;
+     313          53 :     GRB_TRY (GxB_Vector_unpack_Full (t, (void **) &Cp, &Cp_size, NULL, NULL)) ;
+     314          52 :     GRB_TRY (GrB_free (&t)) ;
+     315             : 
+     316             :     //--------------------------------------------------------------------------
+     317             :     // warmup: parent = min (0:n-1, A*1) using the MIN_SECONDI semiring
+     318             :     //--------------------------------------------------------------------------
+     319             : 
+     320             :     // y (i) = min (i, j) for all entries A(i,j).  This warmup phase takes only
+     321             :     // O(n) time, because of how the MIN_SECONDI semiring is implemented in
+     322             :     // SuiteSparse:GraphBLAS.  A is held by row, and the first entry in A(i,:)
+     323             :     // is the minimum index j, so only the first entry in A(i,:) needs to be
+     324             :     // considered for each row i.
+     325             : 
+     326          52 :     GRB_TRY (GrB_Vector_new (&t, Int, n)) ;
+     327          50 :     GRB_TRY (GrB_Vector_new (&y, Int, n)) ;
+     328          48 :     GRB_TRY (GrB_assign (t, NULL, NULL, 0, GrB_ALL, n, NULL)) ;
+     329          47 :     GRB_TRY (GrB_assign (y, NULL, NULL, 0, GrB_ALL, n, NULL)) ;
+     330          46 :     GRB_TRY (GrB_apply (y, NULL, NULL, ramp, y, 0, NULL)) ;
+     331          45 :     GRB_TRY (GrB_mxv (y, NULL, imin, min_2ndi, A, t, NULL)) ;
+     332          45 :     GRB_TRY (GrB_free (&t)) ;
+     333             : 
+     334             :     // The typecast from Int to Uint is required because the ROWINDEX operator
+     335             :     // and MIN_SECONDI do not work in the UINT* domains, as built-in operators.
+     336             :     // parent = (Uint) y
+     337          45 :     GRB_TRY (GrB_Vector_new (&parent, Uint, n)) ;
+     338          43 :     GRB_TRY (GrB_assign (parent, NULL, NULL, y, GrB_ALL, n, NULL)) ;
+     339          42 :     GRB_TRY (GrB_free (&y)) ;
+     340             : 
+     341             :     // copy parent into gp, mngp, and Px.  Px is a non-opaque 64-bit copy of the
+     342             :     // parent GrB_Vector.  The Px array is always of type GrB_Index since it
+     343             :     // must be used as the input array for extractTuples and as Ci for pack_CSR.
+     344             :     // If parent is uint32, GraphBLAS typecasts it to the uint64 Px array.
+     345          42 :     GRB_TRY (GrB_Vector_extractTuples (NULL, Px, &n, parent)) ;
+     346          42 :     GRB_TRY (GrB_Vector_dup (&gp, parent)) ;
+     347          40 :     GRB_TRY (GrB_Vector_dup (&mngp, parent)) ;
+     348          38 :     GRB_TRY (GrB_Vector_new (&gp_new, Uint, n)) ;
+     349          36 :     GRB_TRY (GrB_Vector_new (&t, GrB_BOOL, n)) ;
+     350             : 
+     351             :     //--------------------------------------------------------------------------
+     352             :     // sample phase
+     353             :     //--------------------------------------------------------------------------
+     354             : 
+     355          34 :     if (sampling)
+     356             :     {
+     357             : 
+     358             : // [ todo: GxB_select, using a new operator: GxB_RankUnaryOp, will do all this,
+     359             : // with GxB_Matrix_select_RankOp_Scalar with operator GxB_LEASTRANK and a
+     360             : // GrB_Scalar input equal to FASTSV_SAMPLES.  Built-in operators will be,
+     361             : // (where y is INT64):
+     362             : //
+     363             : //      GxB_LEASTRANK (aij, i, j, k, d, y): select if aij has rank k <= y
+     364             : //      GxB_NLEASTRANK: select if aij has rank k > y
+     365             : //      GxB_GREATESTRANK (...) select if aij has rank k >= (d-y) where
+     366             : //          d = # of entries in A(i,:).
+     367             : //      GxB_NGREATESTRANK (...): select if aij has rank k < (d-y)
+     368             : // and perhaps other operators such as:
+     369             : //      GxB_LEASTRELRANK (...): select aij if rank k <= y*d where y is double
+     370             : //      GxB_GREATESTRELRANK (...): select aij rank k > y*d where y is double
+     371             : //
+     372             : // By default, the rank of aij is its relative position as the kth entry in its
+     373             : // row (from "left" to "right").  If a new GxB setting in the descriptor is
+     374             : // set, then k is the relative position of aij as the kth entry in its column.
+     375             : // The default would be that the rank is the position of aij in its row A(i,:).
+     376             : 
+     377             : // Other:
+     378             : //      give me 3 random items from the row (y = 3)
+     379             : //      give me the 4 biggest *values* in each row (y = 4)
+     380             : 
+     381             : // mxv:
+     382             : //      C = A*diag(D)
+     383             : 
+     384             :         //----------------------------------------------------------------------
+     385             :         // unpack A in CSR format
+     386             :         //----------------------------------------------------------------------
+     387             : 
+     388             :         void *Ax ;
+     389             :         GrB_Index *Ap, *Aj, Ap_size, Aj_size, Ax_size ;
+     390             :         bool A_jumbled, A_iso ;
+     391           4 :         GRB_TRY (GxB_Matrix_unpack_CSR (A, &Ap, &Aj, &Ax,
+     392             :             &Ap_size, &Aj_size, &Ax_size, &A_iso, &A_jumbled, NULL)) ;
+     393             : 
+     394             :         //----------------------------------------------------------------------
+     395             :         // allocate workspace, including space to construct T
+     396             :         //----------------------------------------------------------------------
+     397             : 
+     398           4 :         GrB_Index Tp_size = (n+1) * sizeof (GrB_Index) ;
+     399           4 :         GrB_Index Tj_size = nvals * sizeof (GrB_Index) ;
+     400           4 :         GrB_Index Tx_size = sizeof (bool) ;
+     401           4 :         LG_TRY (LAGraph_Malloc ((void **) &Tp, n+1, sizeof (GrB_Index), msg)) ;
+     402           4 :         LG_TRY (LAGraph_Malloc ((void **) &Tj, nvals, sizeof (GrB_Index),
+     403             :             msg)) ;
+     404           4 :         LG_TRY (LAGraph_Calloc ((void **) &Tx, 1, sizeof (bool), msg)) ;
+     405           4 :         LG_TRY (LAGraph_Malloc ((void **) &range, nthreads + 1,
+     406             :             sizeof (int64_t), msg)) ;
+     407           4 :         LG_TRY (LAGraph_Calloc ((void **) &count, nthreads + 1,
+     408             :             sizeof (GrB_Index), msg)) ;
+     409             : 
+     410             :         //----------------------------------------------------------------------
+     411             :         // define parallel tasks to construct T
+     412             :         //----------------------------------------------------------------------
+     413             : 
+     414             :         // thread tid works on rows range[tid]:range[tid+1]-1 of A and T
+     415             :         int tid;
+     416          12 :         for (tid = 0 ; tid <= nthreads ; tid++)
+     417             :         {
+     418           8 :             range [tid] = (n * tid + nthreads - 1) / nthreads ;
+     419             :         }
+     420             : 
+     421             :         //----------------------------------------------------------------------
+     422             :         // determine the number entries to be constructed in T for each thread
+     423             :         //----------------------------------------------------------------------
+     424             : 
+     425             :         #pragma omp parallel for num_threads(nthreads) schedule(static)
+     426           8 :         for (tid = 0 ; tid < nthreads ; tid++)
+     427             :         {
+     428        9756 :             for (int64_t i = range [tid] ; i < range [tid+1] ; i++)
+     429             :             {
+     430        9752 :                 int64_t deg = Ap [i + 1] - Ap [i] ;
+     431        9752 :                 count [tid + 1] += LAGRAPH_MIN (FASTSV_SAMPLES, deg) ;
+     432             :             }
+     433             :         }
+     434             : 
+     435             :         //----------------------------------------------------------------------
+     436             :         // count = cumsum (count)
+     437             :         //----------------------------------------------------------------------
+     438             : 
+     439           8 :         for (tid = 0 ; tid < nthreads ; tid++)
+     440             :         {
+     441           4 :             count [tid + 1] += count [tid] ;
+     442             :         }
+     443             : 
+     444             :         //----------------------------------------------------------------------
+     445             :         // construct T
+     446             :         //----------------------------------------------------------------------
+     447             : 
+     448             :         // T (i,:) consists of the first FASTSV_SAMPLES of A (i,:).
+     449             : 
+     450             :         #pragma omp parallel for num_threads(nthreads) schedule(static)
+     451           8 :         for (tid = 0 ; tid < nthreads ; tid++)
+     452             :         {
+     453           4 :             GrB_Index p = count [tid] ;
+     454           4 :             Tp [range [tid]] = p ;
+     455        9756 :             for (int64_t i = range [tid] ; i < range [tid+1] ; i++)
+     456             :             {
+     457             :                 // construct T (i,:) from the first entries in A (i,:)
+     458        9752 :                 for (int64_t j = 0 ;
+     459       40390 :                     j < FASTSV_SAMPLES && Ap [i] + j < Ap [i + 1] ; j++)
+     460             :                 {
+     461       30638 :                     Tj [p++] = Aj [Ap [i] + j] ;
+     462             :                 }
+     463        9752 :                 Tp [i + 1] = p ;
+     464             :             }
+     465             :         }
+     466             : 
+     467             :         //----------------------------------------------------------------------
+     468             :         // import the result into the GrB_Matrix T
+     469             :         //----------------------------------------------------------------------
+     470             : 
+     471           4 :         GRB_TRY (GrB_Matrix_new (&T, GrB_BOOL, n, n)) ;
+     472           4 :         GRB_TRY (GxB_Matrix_pack_CSR (T, &Tp, &Tj, &Tx, Tp_size, Tj_size,
+     473             :             Tx_size, /* T is iso: */ true, A_jumbled, NULL)) ;
+     474             : 
+     475             : // ] todo: the above will all be done as a single call to GxB_select.
+     476             : 
+     477             :         //----------------------------------------------------------------------
+     478             :         // find the connected components of T
+     479             :         //----------------------------------------------------------------------
+     480             : 
+     481           4 :         LG_TRY (fastsv (T, parent, mngp, &gp, &gp_new, t, eq, min, min_2nd,
+     482             :             C, &Cp, &Px, &Cx, msg)) ;
+     483             : 
+     484             :         //----------------------------------------------------------------------
+     485             :         // use sampling to estimate the largest connected component in T
+     486             :         //----------------------------------------------------------------------
+     487             : 
+     488             :         // The sampling below computes an estimate of the mode of the parent
+     489             :         // vector, the contents of which are currently in the non-opaque Px
+     490             :         // array.
+     491             : 
+     492             :         // hash table size must be a power of 2
+     493             :         #define HASH_SIZE 1024
+     494             :         // number of samples to insert into the hash table
+     495             :         #define HASH_SAMPLES 864
+     496             :         #define HASH(x) (((x << 4) + x) & (HASH_SIZE-1))
+     497             :         #define NEXT(x) ((x + 23) & (HASH_SIZE-1))
+     498             : 
+     499             :         // allocate and initialize the hash table
+     500           4 :         LG_TRY (LAGraph_Malloc ((void **) &ht_key, HASH_SIZE,
+     501             :             sizeof (GrB_Index), msg)) ;
+     502           4 :         LG_TRY (LAGraph_Calloc ((void **) &ht_count, HASH_SIZE,
+     503             :             sizeof (int), msg)) ;
+     504        4100 :         for (int k = 0 ; k < HASH_SIZE ; k++)
+     505             :         {
+     506        4096 :             ht_key [k] = UINT64_MAX ;
+     507             :         }
+     508             : 
+     509             :         // hash the samples and find the most frequent entry
+     510           4 :         uint64_t seed = n ;         // random number seed
+     511           4 :         int64_t key = -1 ;          // most frequent entry
+     512           4 :         int max_count = 0 ;         // frequency of most frequent entry
+     513        3460 :         for (int64_t k = 0 ; k < HASH_SAMPLES ; k++)
+     514             :         {
+     515             :             // select an entry from Px at random
+     516        3456 :             GrB_Index x = Px [LG_Random60 (&seed) % n] ;
+     517             :             // find x in the hash table
+     518        3456 :             GrB_Index h = HASH (x) ;
+     519        3650 :             while (ht_key [h] != UINT64_MAX && ht_key [h] != x) h = NEXT (h) ;
+     520             :             // add x to the hash table
+     521        3456 :             ht_key [h] = x ;
+     522        3456 :             ht_count [h]++ ;
+     523             :             // keep track of the most frequent value
+     524        3456 :             if (ht_count [h] > max_count)
+     525             :             {
+     526        1864 :                 key = ht_key [h] ;
+     527        1864 :                 max_count = ht_count [h] ;
+     528             :             }
+     529             :         }
+     530             : 
+     531             :         //----------------------------------------------------------------------
+     532             :         // compact the largest connected component in A
+     533             :         //----------------------------------------------------------------------
+     534             : 
+     535             :         // Construct a new matrix T from the input matrix A (the matrix A is
+     536             :         // not changed). The key node is the representative of the (estimated)
+     537             :         // largest component.  T is constructed as a copy of A, except:
+     538             :         // (1) all edges A(i,:) for nodes i in the key component deleted, and
+     539             :         // (2) for nodes i not in the key component, A(i,j) is deleted if
+     540             :         //     j is in the key component.
+     541             :         // (3) If A(i,:) has any deletions from (2), T(i,key) is added to T.
+     542             : 
+     543             : // [ todo: replace this with GxB_extract with GrB_Vector index arrays.
+     544             : // See https://github.com/GraphBLAS/graphblas-api-c/issues/67 .
+     545             : // This method will not insert the new entries T(i,key) for rows i that have
+     546             : // had entries deleted.  That can be done with GrB_assign, with an n-by-1 mask
+     547             : // M computed from the before-and-after row degrees of A and T:
+     548             : // M = (parent != key) && (out_degree(T) < out_degree(A))
+     549             : // J [0] = key.
+     550             : // GxB_Matrix_subassign_BOOL (T, M, NULL, true, GrB_ALL, n, J, 1, NULL)
+     551             : // or with
+     552             : // GrB_Col_assign (T, M, NULL, t, GrB_ALL, j, NULL) with an all-true
+     553             : // vector t.
+     554             : 
+     555             :         // unpack T to reuse the space (all content is overwritten below)
+     556             :         bool T_jumbled, T_iso ;
+     557           4 :         GRB_TRY (GxB_Matrix_unpack_CSR (T, &Tp, &Tj, &Tx, &Tp_size, &Tj_size,
+     558             :             &Tx_size, &T_iso, &T_jumbled, NULL)) ;
+     559             :         #pragma omp parallel for num_threads(nthreads) schedule(static)
+     560           8 :         for (tid = 0 ; tid < nthreads ; tid++)
+     561             :         {
+     562           4 :             GrB_Index p = Ap [range [tid]] ;
+     563             :             // thread tid scans A (range [tid]:range [tid+1]-1,:),
+     564             :             // and constructs T(i,:) for all rows in this range.
+     565        9756 :             for (int64_t i = range [tid] ; i < range [tid+1] ; i++)
+     566             :             {
+     567        9752 :                 int64_t pi = Px [i] ;   // pi = parent (i)
+     568        9752 :                 Tp [i] = p ;            // start the construction of T(i,:)
+     569             :                 // T(i,:) is empty if pi == key
+     570        9752 :                 if (pi != key)
+     571             :                 {
+     572             :                     // scan A(i,:)
+     573       46550 :                     for (GrB_Index pS = Ap [i] ; pS < Ap [i+1] ; pS++)
+     574             :                     {
+     575             :                         // get A(i,j)
+     576       41274 :                         int64_t j = Aj [pS] ;
+     577       41274 :                         if (Px [j] != key)
+     578             :                         {
+     579             :                             // add the entry T(i,j) to T, but skip it if
+     580             :                             // Px [j] is equal to key
+     581       41264 :                             Tj [p++] = j ;
+     582             :                         }
+     583             :                     }
+     584             :                     // Add the entry T(i,key) if there is room for it in T(i,:);
+     585             :                     // if and only if node i is adjacent to a node j in the
+     586             :                     // largest component.  The only way there can be space if
+     587             :                     // at least one T(i,j) appears with Px [j] equal to the key
+     588             :                     // (that is, node j is in the largest connected component,
+     589             :                     // key == Px [j].  One of these j's can then be replaced
+     590             :                     // with the key.  If node i is not adjacent to any node in
+     591             :                     // the largest component, then there is no space in T(i,:)
+     592             :                     // and no new edge to the largest component is added.
+     593        5276 :                     if (p - Tp [i] < Ap [i+1] - Ap [i])
+     594             :                     {
+     595           2 :                         Tj [p++] = key ;
+     596             :                     }
+     597             :                 }
+     598             :             }
+     599             :             // count the number of entries inserted into T by this thread
+     600           4 :             count [tid] = p - Tp [range [tid]] ;
+     601             :         }
+     602             : 
+     603             :         // Compact empty space out of Tj not filled in from the above phase.
+     604           4 :         nvals = 0 ;
+     605           8 :         for (tid = 0 ; tid < nthreads ; tid++)
+     606             :         {
+     607           4 :             memmove (Tj + nvals,
+     608           4 :                 Tj + Tp [range [tid]], sizeof (GrB_Index) * count [tid]) ;
+     609           4 :             nvals += count [tid] ;
+     610           4 :             count [tid] = nvals - count [tid] ;
+     611             :         }
+     612             : 
+     613             :         // Compact empty space out of Tp
+     614             :         #pragma omp parallel for num_threads(nthreads) schedule(static)
+     615           8 :         for (tid = 0 ; tid < nthreads ; tid++)
+     616             :         {
+     617           4 :             GrB_Index p = Tp [range [tid]] ;
+     618        9756 :             for (int64_t i = range [tid] ; i < range [tid+1] ; i++)
+     619             :             {
+     620        9752 :                 Tp [i] -= p - count [tid] ;
+     621             :             }
+     622             :         }
+     623             : 
+     624             :         // finalize T
+     625           4 :         Tp [n] = nvals ;
+     626             : 
+     627             :         // pack T for the final phase
+     628           4 :         GRB_TRY (GxB_Matrix_pack_CSR (T, &Tp, &Tj, &Tx, Tp_size, Tj_size,
+     629             :             Tx_size, T_iso, /* T is now jumbled */ true, NULL)) ;
+     630             : 
+     631             :         // pack A (unchanged since last unpack); this is the original G->A.
+     632           4 :         GRB_TRY (GxB_Matrix_pack_CSR (A, &Ap, &Aj, &Ax, Ap_size, Aj_size,
+     633             :             Ax_size, A_iso, A_jumbled, NULL)) ;
+     634             : 
+     635             : // ].  The unpack/pack of A into Ap, Aj, Ax will not be needed, and G->A
+     636             : // will become truly a read-only matrix.
+     637             : 
+     638             :         // final phase uses the pruned matrix T
+     639           4 :         A = T ;
+     640             :     }
+     641             : 
+     642             :     //--------------------------------------------------------------------------
+     643             :     // check for quick return
+     644             :     //--------------------------------------------------------------------------
+     645             : 
+     646             :     // The sample phase may have already found that G->A has a single component,
+     647             :     // in which case the matrix A is now empty.
+     648             : 
+     649          34 :     if (nvals == 0)
+     650             :     {
+     651           2 :         (*component) = parent ;
+     652           2 :         LG_FREE_WORK ;
+     653           2 :         return (GrB_SUCCESS) ;
+     654             :     }
+     655             : 
+     656             :     //--------------------------------------------------------------------------
+     657             :     // final phase
+     658             :     //--------------------------------------------------------------------------
+     659             : 
+     660          32 :     LG_TRY (fastsv (A, parent, mngp, &gp, &gp_new, t, eq, min, min_2nd,
+     661             :         C, &Cp, &Px, &Cx, msg)) ;
+     662             : 
+     663             :     //--------------------------------------------------------------------------
+     664             :     // free workspace and return result
+     665             :     //--------------------------------------------------------------------------
+     666             : 
+     667          23 :     (*component) = parent ;
+     668          23 :     LG_FREE_WORK ;
+     669          23 :     return (GrB_SUCCESS) ;
+     670             : #endif
+     671             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/algorithm/index-sort-f.html b/src/algorithm/index-sort-f.html new file mode 100644 index 0000000000..cfda8250e9 --- /dev/null +++ b/src/algorithm/index-sort-f.html @@ -0,0 +1,203 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/algorithm + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/algorithmHitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:805805100.0 %
Date:2024-08-29 20:08:04Functions:1616100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
LAGr_SingleSourceShortestPath.c +
100.0%
+
100.0 %161 / 161100.0 %1 / 1
LAGr_BreadthFirstSearch.c +
100.0%
+
100.0 %2 / 2100.0 %1 / 1
LG_BreadthFirstSearch_vanilla.c +
100.0%
+
100.0 %48 / 48100.0 %1 / 1
LAGr_Betweenness.c +
100.0%
+
100.0 %70 / 70100.0 %1 / 1
LAGr_PageRankGAP.c +
100.0%
+
100.0 %39 / 39100.0 %1 / 1
LG_BreadthFirstSearch_SSGrB.c +
100.0%
+
100.0 %90 / 90100.0 %1 / 1
LAGraph_TriangleCount.c +
100.0%
+
100.0 %5 / 5100.0 %1 / 1
LAGr_PageRank.c +
100.0%
+
100.0 %54 / 54100.0 %1 / 1
LAGr_ConnectedComponents.c +
100.0%
+
100.0 %2 / 2100.0 %1 / 1
LG_CC_FastSV6.c +
100.0%
+
100.0 %162 / 162100.0 %2 / 2
LAGr_TriangleCount.c +
100.0%
+
100.0 %103 / 103100.0 %2 / 2
LG_CC_Boruvka.c +
100.0%
+
100.0 %69 / 69100.0 %3 / 3
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/algorithm/index-sort-l.html b/src/algorithm/index-sort-l.html new file mode 100644 index 0000000000..7e0465f1ea --- /dev/null +++ b/src/algorithm/index-sort-l.html @@ -0,0 +1,203 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/algorithm + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/algorithmHitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:805805100.0 %
Date:2024-08-29 20:08:04Functions:1616100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
LAGr_BreadthFirstSearch.c +
100.0%
+
100.0 %2 / 2100.0 %1 / 1
LAGr_ConnectedComponents.c +
100.0%
+
100.0 %2 / 2100.0 %1 / 1
LAGraph_TriangleCount.c +
100.0%
+
100.0 %5 / 5100.0 %1 / 1
LAGr_PageRankGAP.c +
100.0%
+
100.0 %39 / 39100.0 %1 / 1
LG_BreadthFirstSearch_vanilla.c +
100.0%
+
100.0 %48 / 48100.0 %1 / 1
LAGr_PageRank.c +
100.0%
+
100.0 %54 / 54100.0 %1 / 1
LG_CC_Boruvka.c +
100.0%
+
100.0 %69 / 69100.0 %3 / 3
LAGr_Betweenness.c +
100.0%
+
100.0 %70 / 70100.0 %1 / 1
LG_BreadthFirstSearch_SSGrB.c +
100.0%
+
100.0 %90 / 90100.0 %1 / 1
LAGr_TriangleCount.c +
100.0%
+
100.0 %103 / 103100.0 %2 / 2
LAGr_SingleSourceShortestPath.c +
100.0%
+
100.0 %161 / 161100.0 %1 / 1
LG_CC_FastSV6.c +
100.0%
+
100.0 %162 / 162100.0 %2 / 2
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/algorithm/index.html b/src/algorithm/index.html new file mode 100644 index 0000000000..555cfc1e6d --- /dev/null +++ b/src/algorithm/index.html @@ -0,0 +1,203 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/algorithm + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/algorithmHitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:805805100.0 %
Date:2024-08-29 20:08:04Functions:1616100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
LAGr_Betweenness.c +
100.0%
+
100.0 %70 / 70100.0 %1 / 1
LAGr_BreadthFirstSearch.c +
100.0%
+
100.0 %2 / 2100.0 %1 / 1
LAGr_ConnectedComponents.c +
100.0%
+
100.0 %2 / 2100.0 %1 / 1
LAGr_PageRank.c +
100.0%
+
100.0 %54 / 54100.0 %1 / 1
LAGr_PageRankGAP.c +
100.0%
+
100.0 %39 / 39100.0 %1 / 1
LAGr_SingleSourceShortestPath.c +
100.0%
+
100.0 %161 / 161100.0 %1 / 1
LAGr_TriangleCount.c +
100.0%
+
100.0 %103 / 103100.0 %2 / 2
LAGraph_TriangleCount.c +
100.0%
+
100.0 %5 / 5100.0 %1 / 1
LG_BreadthFirstSearch_SSGrB.c +
100.0%
+
100.0 %90 / 90100.0 %1 / 1
LG_BreadthFirstSearch_vanilla.c +
100.0%
+
100.0 %48 / 48100.0 %1 / 1
LG_CC_Boruvka.c +
100.0%
+
100.0 %69 / 69100.0 %3 / 3
LG_CC_FastSV6.c +
100.0%
+
100.0 %162 / 162100.0 %2 / 2
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/LG_brutal_malloc.c.func-sort-c.html b/src/test/LG_brutal_malloc.c.func-sort-c.html new file mode 100644 index 0000000000..2d9a765e8d --- /dev/null +++ b/src/test/LG_brutal_malloc.c.func-sort-c.html @@ -0,0 +1,88 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/LG_brutal_malloc.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - LG_brutal_malloc.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:2929100.0 %
Date:2024-08-29 20:08:04Functions:44100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_brutal_calloc681
LG_brutal_realloc25016
LG_brutal_free880536
LG_brutal_malloc918370
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/LG_brutal_malloc.c.func.html b/src/test/LG_brutal_malloc.c.func.html new file mode 100644 index 0000000000..2cbeb83932 --- /dev/null +++ b/src/test/LG_brutal_malloc.c.func.html @@ -0,0 +1,88 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/LG_brutal_malloc.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - LG_brutal_malloc.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:2929100.0 %
Date:2024-08-29 20:08:04Functions:44100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_brutal_calloc681
LG_brutal_free880536
LG_brutal_malloc918370
LG_brutal_realloc25016
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/LG_brutal_malloc.c.gcov.html b/src/test/LG_brutal_malloc.c.gcov.html new file mode 100644 index 0000000000..0c08ede935 --- /dev/null +++ b/src/test/LG_brutal_malloc.c.gcov.html @@ -0,0 +1,240 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/LG_brutal_malloc.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - LG_brutal_malloc.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:2929100.0 %
Date:2024-08-29 20:08:04Functions:44100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LG_brutal_malloc: brutal memory debugging
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // To enable brutal memory debugging, these four functions must be passed to
+      19             : // LAGr_Init.
+      20             : 
+      21             : #include "LG_internal.h"
+      22             : #include "LG_test.h"
+      23             : 
+      24             : //------------------------------------------------------------------------------
+      25             : // global variables: LG_brutal and LG_nmalloc
+      26             : //------------------------------------------------------------------------------
+      27             : 
+      28             : // If LG_brutal >= 0, then that value gives the # of malloc/calloc/realloc
+      29             : // calls that will succeed.  Each time malloc/calloc/realloc is called, the
+      30             : // LG_brutal count is decremented.  Once it reaches zero, no more memory
+      31             : // allocations will occur, and LG_brutal_malloc, etc, all pretend to fail
+      32             : // and return NULL.
+      33             : 
+      34             : // If LG_brutal is negative, the LG_brutal_malloc/calloc/realloc functions act
+      35             : // like the regular malloc/calloc/realloc functions, with no pretend failures.
+      36             : 
+      37             : // LG_nmalloc is the count of the # of allocated blocks.  It is incremented by
+      38             : // LG_brutal_malloc/calloc and by LG_brutal_realloc if a new block is allocated.
+      39             : // It is decremented by LG_brutal_free.  After LAGraph_Finalize is called,
+      40             : // this value should be zero.  If nonzero, a memory leak has occured.
+      41             : 
+      42             : LG_TEST_PUBLIC int64_t LG_brutal = -1 ;
+      43             : LG_TEST_PUBLIC int64_t LG_nmalloc = 0 ;
+      44             : 
+      45             : //------------------------------------------------------------------------------
+      46             : // LG_brutal_malloc
+      47             : //------------------------------------------------------------------------------
+      48             : 
+      49             : LG_TEST_PUBLIC
+      50      918370 : void *LG_brutal_malloc      // return pointer to allocated block of memory
+      51             : (
+      52             :     size_t size             // # of bytes to allocate
+      53             : )
+      54             : {
+      55             :     void *p ;
+      56      918370 :     if (LG_brutal == 0)
+      57             :     {
+      58             :         // pretend to fail
+      59       37834 :         p = NULL ;
+      60             :     }
+      61             :     else
+      62             :     {
+      63             :         // malloc a new block
+      64             :         #pragma omp critical (LG_brutal_malloc_critical)
+      65             :         {
+      66             :             // malloc the block of memory (of size at least 1 byte)
+      67      880536 :             p = malloc (LAGRAPH_MAX (1, size)) ;
+      68      880536 :             if (LG_brutal > 0)
+      69             :             {
+      70             :                 // one step closer to pretending to fail
+      71      863933 :                 LG_brutal-- ;
+      72             :             }
+      73      880536 :             if (p != NULL)
+      74             :             {
+      75             :                 // one more block of memory successfully allocated
+      76      880536 :                 LG_nmalloc++ ;
+      77             :             }
+      78             :         }
+      79             :     }
+      80      918370 :     return (p) ;
+      81             : }
+      82             : 
+      83             : //------------------------------------------------------------------------------
+      84             : // LG_brutal_calloc
+      85             : //------------------------------------------------------------------------------
+      86             : 
+      87             : LG_TEST_PUBLIC
+      88         681 : void *LG_brutal_calloc      // return pointer to allocated block of memory
+      89             : (
+      90             :     size_t nitems,          // # of items to allocate
+      91             :     size_t itemsize         // # of bytes per item
+      92             : )
+      93             : {
+      94         681 :     size_t size = LAGRAPH_MAX (1, nitems * itemsize) ;
+      95         681 :     void *p = LG_brutal_malloc (size) ;
+      96         681 :     if (p != NULL)
+      97             :     {
+      98         680 :         memset (p, 0, size) ;
+      99             :     }
+     100         681 :     return (p) ;
+     101             : }
+     102             : 
+     103             : //------------------------------------------------------------------------------
+     104             : // LG_brutal_free
+     105             : //------------------------------------------------------------------------------
+     106             : 
+     107             : LG_TEST_PUBLIC
+     108      880536 : void LG_brutal_free
+     109             : (
+     110             :     void *p                 // block to free
+     111             : )
+     112             : {
+     113      880536 :     if (p != NULL)
+     114             :     {
+     115             :         #pragma omp critical (LG_brutal_malloc_critical)
+     116             :         {
+     117             :             // free the block
+     118      880536 :             free (p) ;
+     119             :             // one less block of memory allocated
+     120      880536 :             LG_nmalloc-- ;
+     121             :         }
+     122             :     }
+     123      880536 : }
+     124             : 
+     125             : //------------------------------------------------------------------------------
+     126             : // LG_brutal_realloc
+     127             : //------------------------------------------------------------------------------
+     128             : 
+     129             : LG_TEST_PUBLIC
+     130       25016 : void *LG_brutal_realloc     // return pointer to reallocated memory
+     131             : (
+     132             :     void *p,                // block to realloc
+     133             :     size_t size             // new size of the block
+     134             : )
+     135             : {
+     136       25016 :     if (p == NULL)
+     137             :     {
+     138             :         // malloc a new block
+     139           4 :         p = LG_brutal_malloc (size) ;
+     140             :     }
+     141             :     else
+     142             :     {
+     143             :         // realloc an existing block
+     144             :         #pragma omp critical (LG_brutal_malloc_critical)
+     145             :         {
+     146       25012 :             if (LG_brutal == 0)
+     147             :             {
+     148             :                 // pretend to fail
+     149         658 :                 p = NULL ;
+     150             :             }
+     151             :             else
+     152             :             {
+     153             :                 // realloc the block
+     154       24354 :                 p = realloc (p, size) ;
+     155       24354 :                 if (LG_brutal > 0)
+     156             :                 {
+     157             :                     // one step closer to pretending to fail
+     158       24327 :                     LG_brutal-- ;
+     159             :                 }
+     160             :             }
+     161             :         }
+     162             :     }
+     163       25016 :     return (p) ;
+     164             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/LG_brutal_setup.c.func-sort-c.html b/src/test/LG_brutal_setup.c.func-sort-c.html new file mode 100644 index 0000000000..f15bf60b8f --- /dev/null +++ b/src/test/LG_brutal_setup.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/LG_brutal_setup.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - LG_brutal_setup.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:88100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_brutal_setup27
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/LG_brutal_setup.c.func.html b/src/test/LG_brutal_setup.c.func.html new file mode 100644 index 0000000000..3928075e74 --- /dev/null +++ b/src/test/LG_brutal_setup.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/LG_brutal_setup.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - LG_brutal_setup.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:88100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_brutal_setup27
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/LG_brutal_setup.c.gcov.html b/src/test/LG_brutal_setup.c.gcov.html new file mode 100644 index 0000000000..bdb6dee36e --- /dev/null +++ b/src/test/LG_brutal_setup.c.gcov.html @@ -0,0 +1,112 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/LG_brutal_setup.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - LG_brutal_setup.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:88100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LG_brutal_setup.c: setup an LAGraph test with brutal memory testing
+       3             : // -----------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include "LG_internal.h"
+      19             : #include "LG_test.h"
+      20             : 
+      21          27 : int LG_brutal_setup (char *msg)
+      22             : {
+      23          27 :     LG_brutal = -1 ;        // disable brutal testing for now
+      24          27 :     LG_nmalloc = 0 ;        // assuming nothing is malloc'd
+      25          27 :     int result = LAGr_Init (GrB_NONBLOCKING,
+      26             :         LG_brutal_malloc, LG_brutal_calloc,
+      27             :         LG_brutal_realloc, LG_brutal_free, msg) ;
+      28          27 :     if (result != 0) return (result) ;
+      29             :     #if LAGRAPH_SUITESPARSE
+      30             :     // disable the SuiteSparse:GraphBLAS memory pool
+      31             :     int64_t free_pool_limit [64] ;
+      32          27 :     memset (free_pool_limit, 0, 64 * sizeof (int64_t)) ;
+      33          27 :     result = GxB_set (GxB_MEMORY_POOL, free_pool_limit) ;
+      34             :     #endif
+      35          27 :     return (result) ;
+      36             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/LG_brutal_teardown.c.func-sort-c.html b/src/test/LG_brutal_teardown.c.func-sort-c.html new file mode 100644 index 0000000000..ea20236a90 --- /dev/null +++ b/src/test/LG_brutal_teardown.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/LG_brutal_teardown.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - LG_brutal_teardown.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:44100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_brutal_teardown27
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/LG_brutal_teardown.c.func.html b/src/test/LG_brutal_teardown.c.func.html new file mode 100644 index 0000000000..4f159b8bf1 --- /dev/null +++ b/src/test/LG_brutal_teardown.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/LG_brutal_teardown.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - LG_brutal_teardown.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:44100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_brutal_teardown27
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/LG_brutal_teardown.c.gcov.html b/src/test/LG_brutal_teardown.c.gcov.html new file mode 100644 index 0000000000..55c3f0d8f7 --- /dev/null +++ b/src/test/LG_brutal_teardown.c.gcov.html @@ -0,0 +1,103 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/LG_brutal_teardown.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - LG_brutal_teardown.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:44100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LG_brutal_teardown.c: teardown an LAGraph test with brutal memory testing
+       3             : // -----------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include "LG_internal.h"
+      19             : #include "LG_test.h"
+      20             : 
+      21          27 : int LG_brutal_teardown (char *msg)
+      22             : {
+      23          27 :     LG_TRY (LAGraph_Finalize (msg)) ;
+      24             :     // nothing must be left allocated
+      25          27 :     if (LG_nmalloc != 0) printf ("Leak! %g\n", (double) LG_nmalloc) ;
+      26          27 :     return ((LG_nmalloc == 0) ? 0 : -911) ;
+      27             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/LG_check_bfs.c.func-sort-c.html b/src/test/LG_check_bfs.c.func-sort-c.html new file mode 100644 index 0000000000..5157199df7 --- /dev/null +++ b/src/test/LG_check_bfs.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/LG_check_bfs.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - LG_check_bfs.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:7171100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_check_bfs1539
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/LG_check_bfs.c.func.html b/src/test/LG_check_bfs.c.func.html new file mode 100644 index 0000000000..aa97d97b23 --- /dev/null +++ b/src/test/LG_check_bfs.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/LG_check_bfs.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - LG_check_bfs.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:7171100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_check_bfs1539
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/LG_check_bfs.c.gcov.html b/src/test/LG_check_bfs.c.gcov.html new file mode 100644 index 0000000000..488afb17e2 --- /dev/null +++ b/src/test/LG_check_bfs.c.gcov.html @@ -0,0 +1,321 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/LG_check_bfs.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - LG_check_bfs.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:7171100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph/src/test/LG_check_bfs: stand-alone test for BFS
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #define LG_FREE_WORK                                \
+      19             : {                                                   \
+      20             :     LAGraph_Free ((void **) &queue, NULL) ;         \
+      21             :     LAGraph_Free ((void **) &level_check, NULL) ;   \
+      22             :     LAGraph_Free ((void **) &level_in, NULL) ;      \
+      23             :     LAGraph_Free ((void **) &parent_in, NULL) ;     \
+      24             :     LAGraph_Free ((void **) &visited, NULL) ;       \
+      25             :     LAGraph_Free ((void **) &neighbors, NULL) ;     \
+      26             :     GrB_free (&Row) ;                               \
+      27             : }
+      28             : 
+      29             : #define LG_FREE_ALL                                 \
+      30             : {                                                   \
+      31             :     LG_FREE_WORK ;                                  \
+      32             :     LAGraph_Free ((void **) &Ap, NULL) ;            \
+      33             :     LAGraph_Free ((void **) &Aj, NULL) ;            \
+      34             :     LAGraph_Free ((void **) &Ax, NULL) ;            \
+      35             : }
+      36             : 
+      37             : #include "LG_internal.h"
+      38             : #include "LG_test.h"
+      39             : 
+      40             : //------------------------------------------------------------------------------
+      41             : // test the results from a BFS
+      42             : //------------------------------------------------------------------------------
+      43             : 
+      44             : // Because this method does on GxB_unpack on G->A, it should not be used in a
+      45             : // brutal memory test, unless the caller is prepared to reconstruct G->A
+      46             : // when the brutal test causes this method to return early.
+      47             : 
+      48        1539 : int LG_check_bfs
+      49             : (
+      50             :     // input
+      51             :     GrB_Vector Level,       // optional; may be NULL
+      52             :     GrB_Vector Parent,      // optional; may be NULL
+      53             :     LAGraph_Graph G,
+      54             :     GrB_Index src,
+      55             :     char *msg
+      56             : )
+      57             : {
+      58             : 
+      59             :     //--------------------------------------------------------------------------
+      60             :     // check inputs
+      61             :     //--------------------------------------------------------------------------
+      62             : 
+      63        1539 :     double tt = LAGraph_WallClockTime ( ) ;
+      64             : 
+      65        1539 :     GrB_Vector Row = NULL ;
+      66        1539 :     GrB_Index *Ap = NULL, *Aj = NULL, *neighbors = NULL ;
+      67        1539 :     void *Ax = NULL ;
+      68             :     GrB_Index Ap_size, Aj_size, Ax_size, n, ncols ;
+      69        1539 :     int64_t *queue = NULL, *level_in = NULL, *parent_in = NULL,
+      70        1539 :         *level_check = NULL ;
+      71        1539 :     bool *visited = NULL ;
+      72        1539 :     LG_TRY (LAGraph_CheckGraph (G, msg)) ;
+      73        1539 :     GRB_TRY (GrB_Matrix_nrows (&n, G->A)) ;
+      74        1539 :     GRB_TRY (GrB_Matrix_ncols (&ncols, G->A)) ;
+      75        1539 :     bool print_timings = (n >= 2000) ;
+      76             : 
+      77             :     //--------------------------------------------------------------------------
+      78             :     // allocate workspace
+      79             :     //--------------------------------------------------------------------------
+      80             : 
+      81        1539 :     LG_TRY (LAGraph_Malloc ((void **) &queue, n, sizeof (int64_t), msg)) ;
+      82        1539 :     LG_TRY (LAGraph_Malloc ((void **) &level_check, n, sizeof (int64_t), msg)) ;
+      83             : 
+      84             :     //--------------------------------------------------------------------------
+      85             :     // get the contents of the Level and Parent vectors
+      86             :     //--------------------------------------------------------------------------
+      87             : 
+      88        1539 :     if (Level != NULL)
+      89             :     {
+      90        1179 :         LG_TRY (LAGraph_Malloc ((void **) &level_in, n, sizeof (int64_t), msg)) ;
+      91        1179 :         LG_TRY (LG_check_vector (level_in, Level, n, -1)) ;
+      92             :     }
+      93             : 
+      94        1539 :     if (Parent != NULL)
+      95             :     {
+      96         932 :         LG_TRY (LAGraph_Malloc ((void **) &parent_in, n, sizeof (int64_t), msg)) ;
+      97         932 :         LG_TRY (LG_check_vector (parent_in, Parent, n, -1)) ;
+      98             :     }
+      99             : 
+     100             :     //--------------------------------------------------------------------------
+     101             :     // unpack the matrix in CSR form for SuiteSparse:GraphBLAS
+     102             :     //--------------------------------------------------------------------------
+     103             : 
+     104             :     #if LAGRAPH_SUITESPARSE
+     105             :     bool iso, jumbled ;
+     106        1539 :     GRB_TRY (GxB_Matrix_unpack_CSR (G->A,
+     107             :         &Ap, &Aj, &Ax, &Ap_size, &Aj_size, &Ax_size, &iso, &jumbled, NULL)) ;
+     108             :     #endif
+     109             : 
+     110             :     //--------------------------------------------------------------------------
+     111             :     // compute the level of each node
+     112             :     //--------------------------------------------------------------------------
+     113             : 
+     114        1539 :     if (print_timings)
+     115             :     {
+     116          72 :         tt = LAGraph_WallClockTime ( ) - tt ;
+     117          72 :         printf ("LG_check_bfs init  time: %g sec\n", tt) ;
+     118          72 :         tt = LAGraph_WallClockTime ( ) ;
+     119             :     }
+     120             : 
+     121        1539 :     queue [0] = src ;
+     122        1539 :     int64_t head = 0 ;
+     123        1539 :     int64_t tail = 1 ;
+     124        1539 :     LG_TRY (LAGraph_Calloc ((void **) &visited, n, sizeof (bool), msg)) ;
+     125        1539 :     visited [src] = true ;      // src is visited, and is level 0
+     126             : 
+     127      279809 :     for (int64_t i = 0 ; i < n ; i++)
+     128             :     {
+     129      278270 :         level_check [i] = -1 ;
+     130             :     }
+     131        1539 :     level_check [src] = 0 ;
+     132             : 
+     133             :     #if !LAGRAPH_SUITESPARSE
+     134             :     GRB_TRY (GrB_Vector_new (&Row, GrB_BOOL, n)) ;
+     135             :     LG_TRY (LAGraph_Malloc ((void **) &neighbors, n, sizeof (GrB_Index), msg)) ;
+     136             :     #endif
+     137             : 
+     138      277589 :     while (head < tail)
+     139             :     {
+     140             :         // dequeue the node at the head of the queue
+     141      276050 :         int64_t u = queue [head++] ;
+     142             : 
+     143             :         #if LAGRAPH_SUITESPARSE
+     144             :         // directly access the indices of entries in A(u,:)
+     145      276050 :         GrB_Index degree = Ap [u+1] - Ap [u] ;
+     146      276050 :         GrB_Index *node_u_adjacency_list = Aj + Ap [u] ;
+     147             :         #else
+     148             :         // extract the indices of entries in A(u,:)
+     149             :         GrB_Index degree = n ;
+     150             :         GRB_TRY (GrB_Col_extract (Row, NULL, NULL, G->A, GrB_ALL, n, u,
+     151             :             GrB_DESC_T0)) ;
+     152             :         GRB_TRY (GrB_Vector_extractTuples_BOOL (neighbors, NULL, &degree, Row));
+     153             :         GrB_Index *node_u_adjacency_list = neighbors ;
+     154             :         #endif
+     155             : 
+     156             :         // traverse all entries in A(u,:)
+     157     7652626 :         for (int64_t k = 0 ; k < degree ; k++)
+     158             :         {
+     159             :             // consider edge (u,v)
+     160     7376576 :             int64_t v = node_u_adjacency_list [k] ;
+     161     7376576 :             if (!visited [v])
+     162             :             {
+     163             :                 // node v is not yet visited; set its level and add to the
+     164             :                 // end of the queue
+     165      274511 :                 visited [v] = true ;
+     166      274511 :                 level_check [v] = level_check [u] + 1 ;
+     167      274511 :                 queue [tail++] = v ;
+     168             :             }
+     169             :         }
+     170             :     }
+     171             : 
+     172        1539 :     if (print_timings)
+     173             :     {
+     174          72 :         tt = LAGraph_WallClockTime ( ) - tt ;
+     175          72 :         printf ("LG_check_bfs bfs   time: %g sec\n", tt) ;
+     176          72 :         tt = LAGraph_WallClockTime ( ) ;
+     177             :     }
+     178             : 
+     179             :     //--------------------------------------------------------------------------
+     180             :     // repack the matrix in CSR form for SuiteSparse:GraphBLAS
+     181             :     //--------------------------------------------------------------------------
+     182             : 
+     183             :     #if LAGRAPH_SUITESPARSE
+     184        1539 :     GRB_TRY (GxB_Matrix_pack_CSR (G->A,
+     185             :         &Ap, &Aj, &Ax, Ap_size, Aj_size, Ax_size, iso, jumbled, NULL)) ;
+     186             :     #endif
+     187             : 
+     188             :     //--------------------------------------------------------------------------
+     189             :     // check the level of each node
+     190             :     //--------------------------------------------------------------------------
+     191             : 
+     192        1539 :     if (level_in != NULL)
+     193             :     {
+     194      188513 :         for (int64_t i = 0 ; i < n ; i++)
+     195             :         {
+     196      187334 :             bool ok = (level_in [i] == level_check [i]) ;
+     197      187334 :             LG_ASSERT_MSG (ok, -2000, "invalid level") ;
+     198             :         }
+     199             :     }
+     200             : 
+     201             :     //--------------------------------------------------------------------------
+     202             :     // check the parent of each node
+     203             :     //--------------------------------------------------------------------------
+     204             : 
+     205        1539 :     if (parent_in != NULL)
+     206             :     {
+     207      184940 :         for (int64_t i = 0 ; i < n ; i++)
+     208             :         {
+     209      184008 :             if (i == src)
+     210             :             {
+     211             :                 // src node is its own parent
+     212         932 :                 bool ok = (parent_in [src] == src) && (visited [src]) ;
+     213         932 :                 LG_ASSERT_MSG (ok, -2001, "invalid parent") ;
+     214             :             }
+     215      183076 :             else if (visited [i])
+     216             :             {
+     217      181744 :                 int64_t pi = parent_in [i] ;
+     218             :                 // ensure the parent pi is valid and has been visited
+     219      181744 :                 bool ok = (pi >= 0 && pi < n) && visited [pi] ;
+     220      181744 :                 LG_ASSERT_MSG (ok, -2001, "invalid parent") ;
+     221             :                 // ensure the edge (pi,i) exists
+     222             :                 bool x ;
+     223      181744 :                 int info = GrB_Matrix_extractElement_BOOL (&x, G->A, pi, i) ;
+     224      181744 :                 ok = (info == GrB_SUCCESS) ;
+     225      181744 :                 LG_ASSERT_MSG (ok, -2001, "invalid parent") ;
+     226             :                 // ensure the parent's level is ok
+     227      181744 :                 ok = (level_check [i] == level_check [pi] + 1) ;
+     228      181744 :                 LG_ASSERT_MSG (ok, -2001, "invalid parent") ;
+     229             :             }
+     230             :         }
+     231             :     }
+     232             : 
+     233             :     //--------------------------------------------------------------------------
+     234             :     // free workspace and return result
+     235             :     //--------------------------------------------------------------------------
+     236             : 
+     237        1539 :     LG_FREE_WORK ;
+     238             : 
+     239        1539 :     if (print_timings)
+     240             :     {
+     241          72 :         tt = LAGraph_WallClockTime ( ) - tt ;
+     242          72 :         printf ("LG_check_bfs check time: %g sec\n", tt) ;
+     243             :     }
+     244        1539 :     return (GrB_SUCCESS) ;
+     245             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/LG_check_cc.c.func-sort-c.html b/src/test/LG_check_cc.c.func-sort-c.html new file mode 100644 index 0000000000..f69e3eff45 --- /dev/null +++ b/src/test/LG_check_cc.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/LG_check_cc.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - LG_check_cc.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:6363100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_check_cc97
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/LG_check_cc.c.func.html b/src/test/LG_check_cc.c.func.html new file mode 100644 index 0000000000..12f9abc9ec --- /dev/null +++ b/src/test/LG_check_cc.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/LG_check_cc.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - LG_check_cc.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:6363100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_check_cc97
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/LG_check_cc.c.gcov.html b/src/test/LG_check_cc.c.gcov.html new file mode 100644 index 0000000000..643f2e9937 --- /dev/null +++ b/src/test/LG_check_cc.c.gcov.html @@ -0,0 +1,304 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/LG_check_cc.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - LG_check_cc.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:6363100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph/src/test/LG_check_cc: stand-alone test for CC
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #define LG_FREE_WORK                                \
+      19             : {                                                   \
+      20             :     LAGraph_Free ((void **) &queue, NULL) ;         \
+      21             :     LAGraph_Free ((void **) &component_in, NULL) ;  \
+      22             :     LAGraph_Free ((void **) &visited, NULL) ;       \
+      23             :     LAGraph_Free ((void **) &neighbors, NULL) ;     \
+      24             :     GrB_free (&Row) ;                               \
+      25             : }
+      26             : 
+      27             : #define LG_FREE_ALL                                 \
+      28             : {                                                   \
+      29             :     LG_FREE_WORK ;                                  \
+      30             :     LAGraph_Free ((void **) &Ap, NULL) ;            \
+      31             :     LAGraph_Free ((void **) &Aj, NULL) ;            \
+      32             :     LAGraph_Free ((void **) &Ax, NULL) ;            \
+      33             : }
+      34             : 
+      35             : #include "LG_internal.h"
+      36             : #include "LG_test.h"
+      37             : 
+      38             : // The output of LAGr_ConnectedComponents is a vector Component, where
+      39             : // Component(i)=s if node i is in the connected compononent whose
+      40             : // representative node is node s.  If s is a representative, then
+      41             : // Component(s)=s.  The number of connected components in the graph G is the
+      42             : // number of representatives.
+      43             : 
+      44             : //------------------------------------------------------------------------------
+      45             : // test the results from LAGr_ConnectedComponents
+      46             : //------------------------------------------------------------------------------
+      47             : 
+      48             : // Because this method does on GxB_unpack on G->A, it should not be used in a
+      49             : // brutal memory test, unless the caller is prepared to reconstruct G->A
+      50             : // when the brutal test causes this method to return early.
+      51             : 
+      52          97 : int LG_check_cc
+      53             : (
+      54             :     // input
+      55             :     GrB_Vector Component,   // Component(i)=s if node is in Component s
+      56             :     LAGraph_Graph G,
+      57             :     char *msg
+      58             : )
+      59             : {
+      60             : 
+      61             :     //--------------------------------------------------------------------------
+      62             :     // check inputs
+      63             :     //--------------------------------------------------------------------------
+      64             : 
+      65          97 :     double tt = LAGraph_WallClockTime ( ) ;
+      66          97 :     GrB_Vector Row = NULL ;
+      67          97 :     GrB_Index *Ap = NULL, *Aj = NULL, *neighbors = NULL ;
+      68          97 :     void *Ax = NULL ;
+      69             :     GrB_Index Ap_size, Aj_size, Ax_size, n, ncols ;
+      70          97 :     int64_t *queue = NULL, *component_in = NULL ;
+      71          97 :     bool *visited = NULL ;
+      72          97 :     LG_TRY (LAGraph_CheckGraph (G, msg)) ;
+      73          97 :     GRB_TRY (GrB_Matrix_nrows (&n, G->A)) ;
+      74          97 :     GRB_TRY (GrB_Matrix_ncols (&ncols, G->A)) ;
+      75          97 :     LG_ASSERT (Component != NULL, GrB_NULL_POINTER) ;
+      76             : 
+      77          97 :     LG_ASSERT_MSG ((G->kind == LAGraph_ADJACENCY_UNDIRECTED ||
+      78             :        (G->kind == LAGraph_ADJACENCY_DIRECTED &&
+      79             :         G->is_symmetric_structure == LAGraph_TRUE)),
+      80             :         LAGRAPH_SYMMETRIC_STRUCTURE_REQUIRED,
+      81             :         "G->A must be known to be symmetric") ;
+      82             : 
+      83             :     //--------------------------------------------------------------------------
+      84             :     // allocate workspace
+      85             :     //--------------------------------------------------------------------------
+      86             : 
+      87          97 :     LG_TRY (LAGraph_Calloc ((void **) &queue, n, sizeof (int64_t), msg)) ;
+      88             : 
+      89             :     //--------------------------------------------------------------------------
+      90             :     // get the contents of the Component vector
+      91             :     //--------------------------------------------------------------------------
+      92             : 
+      93          97 :     LG_TRY (LAGraph_Malloc ((void **) &component_in, n, sizeof (int64_t), msg)) ;
+      94          97 :     LG_TRY (LG_check_vector (component_in, Component, n, -1)) ;
+      95             : 
+      96             :     //--------------------------------------------------------------------------
+      97             :     // find the # of connected components, according to Component vector
+      98             :     //--------------------------------------------------------------------------
+      99             : 
+     100          97 :     int64_t *count = queue ;        // use queue as workspace
+     101          97 :     int64_t ncomp_in = 0 ;
+     102       65165 :     for (int64_t i = 0 ; i < n ; i++)
+     103             :     {
+     104       65068 :         int64_t comp = component_in [i] ;
+     105       65068 :         LG_ASSERT (comp >= 0 && comp < n, -2000) ;
+     106       65068 :         count [comp]++ ;
+     107       65068 :         if (comp == i)
+     108             :         {
+     109             :             // this is the representative of its component
+     110       27182 :             ncomp_in++ ;
+     111             :         }
+     112             :     }
+     113          97 :     printf ("# of components: %g\n", (double) ncomp_in) ;
+     114             : 
+     115          97 :     if (n < 1000)
+     116             :     {
+     117        1021 :         for (int64_t i = 0 ; i < n ; i++)
+     118             :         {
+     119         956 :             if (component_in [i] == i)
+     120             :             {
+     121         126 :                 printf ("Component %g, size %g\n", (double) i,
+     122         126 :                     (double) count [i]) ;
+     123             :             }
+     124             :         }
+     125             :     }
+     126             : 
+     127             :     //--------------------------------------------------------------------------
+     128             :     // unpack the matrix in CSR form for SuiteSparse:GraphBLAS
+     129             :     //--------------------------------------------------------------------------
+     130             : 
+     131             :     #if LAGRAPH_SUITESPARSE
+     132             :     bool iso, jumbled ;
+     133          97 :     GRB_TRY (GxB_Matrix_unpack_CSR (G->A,
+     134             :         &Ap, &Aj, &Ax, &Ap_size, &Aj_size, &Ax_size, &iso, &jumbled, NULL)) ;
+     135             :     #endif
+     136             : 
+     137             :     //--------------------------------------------------------------------------
+     138             :     // find the connected components via repeated BFS
+     139             :     //--------------------------------------------------------------------------
+     140             : 
+     141          97 :     tt = LAGraph_WallClockTime ( ) - tt ;
+     142          97 :     printf ("LG_check_cc init  time: %g sec\n", tt) ;
+     143          97 :     tt = LAGraph_WallClockTime ( ) ;
+     144             : 
+     145          97 :     LG_TRY (LAGraph_Calloc ((void **) &visited, n, sizeof (bool), msg)) ;
+     146             : 
+     147             :     #if !LAGRAPH_SUITESPARSE
+     148             :     GRB_TRY (GrB_Vector_new (&Row, GrB_BOOL, n)) ;
+     149             :     LG_TRY (LAGraph_Malloc ((void **) &neighbors, n, sizeof (GrB_Index), msg)) ;
+     150             :     #endif
+     151             : 
+     152          97 :     int64_t ncomp = 0 ;
+     153             : 
+     154       65165 :     for (int64_t src = 0 ; src < n ; src++)
+     155             :     {
+     156             :         // skip this node if already visited
+     157       65068 :         if (visited [src]) continue ;
+     158             : 
+     159             :         // src node is part of a new connected component, comp
+     160       27182 :         int64_t comp = component_in [src] ;
+     161       27182 :         ncomp++ ;
+     162       27182 :         LG_ASSERT_MSG (ncomp <= ncomp_in, -2001, "wrong # of components") ;
+     163             : 
+     164       27182 :         queue [0] = src ;
+     165       27182 :         int64_t head = 0 ;
+     166       27182 :         int64_t tail = 1 ;
+     167       27182 :         visited [src] = true ;      // src is visited
+     168             : 
+     169       92250 :         while (head < tail)
+     170             :         {
+     171             :             // dequeue the node at the head of the queue
+     172       65068 :             int64_t u = queue [head++] ;
+     173             : 
+     174             :             #if LAGRAPH_SUITESPARSE
+     175             :             // directly access the indices of entries in A(u,:)
+     176       65068 :             GrB_Index degree = Ap [u+1] - Ap [u] ;
+     177       65068 :             GrB_Index *node_u_adjacency_list = Aj + Ap [u] ;
+     178             :             #else
+     179             :             // extract the indices of entries in A(u,:)
+     180             :             GrB_Index degree = n ;
+     181             :             GRB_TRY (GrB_Col_extract (Row, NULL, NULL, G->A, GrB_ALL, n, u,
+     182             :                 GrB_DESC_T0)) ;
+     183             :             GRB_TRY (GrB_Vector_extractTuples_BOOL (neighbors, NULL, &degree,
+     184             :                 Row)) ;
+     185             :             GrB_Index *node_u_adjacency_list = neighbors ;
+     186             :             #endif
+     187             : 
+     188             :             // traverse all entries in A(u,:)
+     189     1017016 :             for (int64_t k = 0 ; k < degree ; k++)
+     190             :             {
+     191             :                 // consider edge (u,v)
+     192      951948 :                 int64_t v = node_u_adjacency_list [k] ;
+     193             :                 // ensure v is in the same connected component as the src node
+     194      951948 :                 LG_ASSERT (comp == component_in [u], -2002) ;
+     195             :                 // printf ("    seen: %ld\n", v) ;
+     196      951948 :                 if (!visited [v])
+     197             :                 {
+     198             :                     // node v is not yet visited; set its level and add to the
+     199             :                     // end of the queue
+     200       37886 :                     visited [v] = true ;
+     201       37886 :                     queue [tail++] = v ;
+     202             :                 }
+     203             :             }
+     204             :         }
+     205             :     }
+     206             : 
+     207          97 :     LG_ASSERT_MSG (ncomp == ncomp_in, -2001, "wrong # of components") ;
+     208             : 
+     209          97 :     tt = LAGraph_WallClockTime ( ) - tt ;
+     210          97 :     printf ("LG_check_cc component time: %g sec\n", tt) ;
+     211          97 :     tt = LAGraph_WallClockTime ( ) ;
+     212             : 
+     213             :     //--------------------------------------------------------------------------
+     214             :     // repack the matrix in CSR form for SuiteSparse:GraphBLAS
+     215             :     //--------------------------------------------------------------------------
+     216             : 
+     217             :     #if LAGRAPH_SUITESPARSE
+     218          97 :     GRB_TRY (GxB_Matrix_pack_CSR (G->A,
+     219             :         &Ap, &Aj, &Ax, Ap_size, Aj_size, Ax_size, iso, jumbled, NULL)) ;
+     220             :     #endif
+     221             : 
+     222          97 :     LG_FREE_WORK ;
+     223             : 
+     224          97 :     tt = LAGraph_WallClockTime ( ) - tt ;
+     225          97 :     printf ("LG_check_cc check time: %g sec\n", tt) ;
+     226             : 
+     227          97 :     return (GrB_SUCCESS) ;
+     228             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/LG_check_export.c.func-sort-c.html b/src/test/LG_check_export.c.func-sort-c.html new file mode 100644 index 0000000000..50ce7c220e --- /dev/null +++ b/src/test/LG_check_export.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/LG_check_export.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - LG_check_export.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:5959100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_check_export443
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/LG_check_export.c.func.html b/src/test/LG_check_export.c.func.html new file mode 100644 index 0000000000..29d7f4957f --- /dev/null +++ b/src/test/LG_check_export.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/LG_check_export.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - LG_check_export.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:5959100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_check_export443
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/LG_check_export.c.gcov.html b/src/test/LG_check_export.c.gcov.html new file mode 100644 index 0000000000..3af9dffffd --- /dev/null +++ b/src/test/LG_check_export.c.gcov.html @@ -0,0 +1,223 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/LG_check_export.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - LG_check_export.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:5959100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LG_check_export: export G->A for testing
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // Export G->A in CSR format, for testing only.
+      19             : // See test_export for a brutal memory test of this method.
+      20             : 
+      21             : #define LG_FREE_ALL                             \
+      22             : {                                               \
+      23             :     LAGraph_Free ((void **) Ap_handle, NULL) ;  \
+      24             :     LAGraph_Free ((void **) Aj_handle, NULL) ;  \
+      25             :     LAGraph_Free ((void **) Ax_handle, NULL) ;  \
+      26             : }
+      27             : 
+      28             : #include "LG_internal.h"
+      29             : #include "LG_test.h"
+      30             : 
+      31         443 : int LG_check_export
+      32             : (
+      33             :     // input
+      34             :     LAGraph_Graph G,        // export G->A in CSR format
+      35             :     // output
+      36             :     GrB_Index **Ap_handle,  // size Ap_len on output
+      37             :     GrB_Index **Aj_handle,  // size Aj_len on output
+      38             :     void **Ax_handle,       // size Ax_len * typesize on output
+      39             :     GrB_Index *Ap_len,
+      40             :     GrB_Index *Aj_len,
+      41             :     GrB_Index *Ax_len,
+      42             :     size_t *typesize,       // size of the type of A
+      43             :     char *msg
+      44             : )
+      45             : {
+      46         443 :     LG_CLEAR_MSG ;
+      47             : 
+      48         443 :     GrB_Index *Ap = NULL, *Aj = NULL ;
+      49         443 :     void *Ax = NULL ;
+      50         443 :     LG_TRY (LAGraph_CheckGraph (G, msg)) ;
+      51             : 
+      52         443 :     LG_ASSERT_MSG (Ap_handle != NULL, GrB_NULL_POINTER, "&Ap is NULL") ;
+      53         443 :     LG_ASSERT_MSG (Aj_handle != NULL, GrB_NULL_POINTER, "&Aj is NULL") ;
+      54         443 :     LG_ASSERT_MSG (Ax_handle != NULL, GrB_NULL_POINTER, "&Ax is NULL") ;
+      55         443 :     LG_ASSERT_MSG (Ap_len != NULL, GrB_NULL_POINTER, "&Ap_len is NULL") ;
+      56         443 :     LG_ASSERT_MSG (Aj_len != NULL, GrB_NULL_POINTER, "&Aj_len is NULL") ;
+      57         443 :     LG_ASSERT_MSG (Ax_len != NULL, GrB_NULL_POINTER, "&Ax_len is NULL") ;
+      58         443 :     LG_ASSERT_MSG (typesize != NULL, GrB_NULL_POINTER, "&typesize is NULL") ;
+      59             : 
+      60             :     // get the type of G->A
+      61         443 :     GrB_Type atype = NULL ;
+      62             :     char atype_name [LAGRAPH_MAX_NAME_LEN] ;
+      63         443 :     LG_TRY (LAGraph_Matrix_TypeName (atype_name, G->A, msg)) ;
+      64         443 :     LG_TRY (LAGraph_TypeFromName (&atype, atype_name, msg)) ;
+      65             : 
+      66         443 :     size_t s = 0 ;
+      67         443 :     if      (atype == GrB_BOOL  ) s = sizeof (bool    ) ;
+      68         293 :     else if (atype == GrB_INT8  ) s = sizeof (int8_t  ) ;
+      69         283 :     else if (atype == GrB_INT16 ) s = sizeof (int16_t ) ;
+      70         273 :     else if (atype == GrB_INT32 ) s = sizeof (int32_t ) ;
+      71         243 :     else if (atype == GrB_INT64 ) s = sizeof (int64_t ) ;
+      72         146 :     else if (atype == GrB_UINT8 ) s = sizeof (uint8_t ) ;
+      73         136 :     else if (atype == GrB_UINT16) s = sizeof (uint16_t) ;
+      74         126 :     else if (atype == GrB_UINT32) s = sizeof (uint32_t) ;
+      75         125 :     else if (atype == GrB_UINT64) s = sizeof (uint64_t) ;
+      76         115 :     else if (atype == GrB_FP32  ) s = sizeof (float   ) ;
+      77         105 :     else if (atype == GrB_FP64  ) s = sizeof (double  ) ;
+      78         443 :     LG_ASSERT_MSG (s != 0, GrB_NOT_IMPLEMENTED, "unsupported type") ;
+      79         443 :     (*typesize) = s ;
+      80             : 
+      81         443 :     GRB_TRY (GrB_Matrix_exportSize (Ap_len, Aj_len, Ax_len, GrB_CSR_FORMAT,
+      82             :         G->A)) ;
+      83         443 :     LG_TRY (LAGraph_Malloc ((void **) Ap_handle, *Ap_len, sizeof (GrB_Index), msg)) ;
+      84         394 :     LG_TRY (LAGraph_Malloc ((void **) Aj_handle, *Aj_len, sizeof (GrB_Index), msg)) ;
+      85         345 :     LG_TRY (LAGraph_Malloc ((void **) Ax_handle, *Ax_len, s, msg)) ;
+      86         296 :     Ap = (*Ap_handle) ;
+      87         296 :     Aj = (*Aj_handle) ;
+      88         296 :     Ax = (*Ax_handle) ;
+      89             : 
+      90         296 :     if      (atype == GrB_BOOL  )
+      91             :     {
+      92          99 :         GRB_TRY (GrB_Matrix_export (Ap, Aj, (bool     *) Ax,
+      93             :             Ap_len, Aj_len, Ax_len, GrB_CSR_FORMAT, G->A)) ;
+      94             :     }
+      95         197 :     else if (atype == GrB_INT8  )
+      96             :     {
+      97           7 :         GRB_TRY (GrB_Matrix_export (Ap, Aj, (int8_t   *) Ax,
+      98             :             Ap_len, Aj_len, Ax_len, GrB_CSR_FORMAT, G->A)) ;
+      99             :     }
+     100         190 :     else if (atype == GrB_INT16 )
+     101             :     {
+     102           7 :         GRB_TRY (GrB_Matrix_export (Ap, Aj, (int16_t  *) Ax,
+     103             :             Ap_len, Aj_len, Ax_len, GrB_CSR_FORMAT, G->A)) ;
+     104             :     }
+     105         183 :     else if (atype == GrB_INT32 )
+     106             :     {
+     107          21 :         GRB_TRY (GrB_Matrix_export (Ap, Aj, (int32_t  *) Ax,
+     108             :             Ap_len, Aj_len, Ax_len, GrB_CSR_FORMAT, G->A)) ;
+     109             :     }
+     110         162 :     else if (atype == GrB_INT64 )
+     111             :     {
+     112          67 :         GRB_TRY (GrB_Matrix_export (Ap, Aj, (int64_t  *) Ax,
+     113             :             Ap_len, Aj_len, Ax_len, GrB_CSR_FORMAT, G->A)) ;
+     114             :     }
+     115          95 :     else if (atype == GrB_UINT8 )
+     116             :     {
+     117           7 :         GRB_TRY (GrB_Matrix_export (Ap, Aj, (uint8_t  *) Ax,
+     118             :             Ap_len, Aj_len, Ax_len, GrB_CSR_FORMAT, G->A)) ;
+     119             :     }
+     120          88 :     else if (atype == GrB_UINT16)
+     121             :     {
+     122           7 :         GRB_TRY (GrB_Matrix_export (Ap, Aj, (uint16_t *) Ax,
+     123             :             Ap_len, Aj_len, Ax_len, GrB_CSR_FORMAT, G->A)) ;
+     124             :     }
+     125          81 :     else if (atype == GrB_UINT32)
+     126             :     {
+     127           1 :         GRB_TRY (GrB_Matrix_export (Ap, Aj, (uint32_t *) Ax,
+     128             :             Ap_len, Aj_len, Ax_len, GrB_CSR_FORMAT, G->A)) ;
+     129             :     }
+     130          80 :     else if (atype == GrB_UINT64)
+     131             :     {
+     132           7 :         GRB_TRY (GrB_Matrix_export (Ap, Aj, (uint64_t *) Ax,
+     133             :             Ap_len, Aj_len, Ax_len, GrB_CSR_FORMAT, G->A)) ;
+     134             :     }
+     135          73 :     else if (atype == GrB_FP32  )
+     136             :     {
+     137           7 :         GRB_TRY (GrB_Matrix_export (Ap, Aj, (float    *) Ax,
+     138             :             Ap_len, Aj_len, Ax_len, GrB_CSR_FORMAT, G->A)) ;
+     139             :     }
+     140          66 :     else if (atype == GrB_FP64  )
+     141             :     {
+     142          66 :         GRB_TRY (GrB_Matrix_export (Ap, Aj, (double   *) Ax,
+     143             :             Ap_len, Aj_len, Ax_len, GrB_CSR_FORMAT, G->A)) ;
+     144             :     }
+     145             : 
+     146         132 :     return (GrB_SUCCESS) ;
+     147             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/LG_check_sssp.c.func-sort-c.html b/src/test/LG_check_sssp.c.func-sort-c.html new file mode 100644 index 0000000000..8ea05bd463 --- /dev/null +++ b/src/test/LG_check_sssp.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/LG_check_sssp.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - LG_check_sssp.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:135135100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_check_sssp483
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/LG_check_sssp.c.func.html b/src/test/LG_check_sssp.c.func.html new file mode 100644 index 0000000000..c2feb4848f --- /dev/null +++ b/src/test/LG_check_sssp.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/LG_check_sssp.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - LG_check_sssp.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:135135100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_check_sssp483
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/LG_check_sssp.c.gcov.html b/src/test/LG_check_sssp.c.gcov.html new file mode 100644 index 0000000000..103079a589 --- /dev/null +++ b/src/test/LG_check_sssp.c.gcov.html @@ -0,0 +1,460 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/LG_check_sssp.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - LG_check_sssp.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:135135100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph/src/test/LG_check_sssp: stand-alone test for SSSP
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include "LG_internal.h"
+      19             : #include "LG_test.h"
+      20             : 
+      21             : // All computations are done in double precision
+      22             : 
+      23             : typedef double LG_key_t ;
+      24             : typedef struct
+      25             : {
+      26             :     int64_t name ;
+      27             :     LG_key_t key ;
+      28             : }
+      29             : LG_Element ;
+      30             : #include "LG_heap.h"
+      31             : 
+      32             : #undef  LG_FREE_WORK
+      33             : #define LG_FREE_WORK                                    \
+      34             : {                                                       \
+      35             :     LAGraph_Free ((void **) &Heap, NULL) ;              \
+      36             :     LAGraph_Free ((void **) &Iheap, NULL) ;             \
+      37             :     LAGraph_Free ((void **) &distance, NULL) ;          \
+      38             :     LAGraph_Free ((void **) &parent, NULL) ;            \
+      39             :     LAGraph_Free ((void **) &path_length_in, NULL) ;    \
+      40             :     LAGraph_Free ((void **) &reachable, NULL) ;         \
+      41             :     LAGraph_Free ((void **) &reachable_in, NULL) ;      \
+      42             :     LAGraph_Free ((void **) &neighbor_weights, NULL) ;  \
+      43             :     LAGraph_Free ((void **) &neighbors, NULL) ;         \
+      44             :     GrB_free (&Row) ;                                   \
+      45             : }
+      46             : 
+      47             : #undef  LG_FREE_ALL
+      48             : #define LG_FREE_ALL                                     \
+      49             : {                                                       \
+      50             :     LG_FREE_WORK ;                                      \
+      51             :     LAGraph_Free ((void **) &Ap, NULL) ;                \
+      52             :     LAGraph_Free ((void **) &Aj, NULL) ;                \
+      53             :     LAGraph_Free ((void **) &Ax, NULL) ;                \
+      54             : }
+      55             : 
+      56             : //------------------------------------------------------------------------------
+      57             : // test the results from SSSP
+      58             : //------------------------------------------------------------------------------
+      59             : 
+      60             : // Because this method does on GxB_unpack on G->A, it should not be used in a
+      61             : // brutal memory test, unless the caller is prepared to reconstruct G->A
+      62             : // when the brutal test causes this method to return early.
+      63             : 
+      64         483 : int LG_check_sssp
+      65             : (
+      66             :     // input
+      67             :     GrB_Vector Path_Length,     // Path_Length(i) is the length of the
+      68             :                                 // shortest path from src to node i.
+      69             :     LAGraph_Graph G,            // all edge weights must be > 0
+      70             :     GrB_Index src,
+      71             :     char *msg
+      72             : )
+      73             : {
+      74             : 
+      75             :     //--------------------------------------------------------------------------
+      76             :     // check inputs
+      77             :     //--------------------------------------------------------------------------
+      78             : 
+      79         483 :     GrB_Vector Row = NULL ;
+      80         483 :     GrB_Index *Ap = NULL, *Aj = NULL, *neighbors = NULL ;
+      81             :     GrB_Index Ap_size, Aj_size, Ax_size, n, ncols ;
+      82         483 :     int64_t *queue = NULL, *Iheap = NULL, *parent = NULL ;
+      83         483 :     LG_Element *Heap = NULL ;
+      84             : 
+      85         483 :     double *path_length_in = NULL, *distance = NULL, *neighbor_weights = NULL ;
+      86         483 :     void *Ax = NULL ;
+      87         483 :     bool *reachable = NULL, *reachable_in = NULL ;
+      88             : 
+      89         483 :     double tt = LAGraph_WallClockTime ( ) ;
+      90         483 :     LG_TRY (LAGraph_CheckGraph (G, msg)) ;
+      91         483 :     GRB_TRY (GrB_Matrix_nrows (&n, G->A)) ;
+      92         483 :     GRB_TRY (GrB_Matrix_ncols (&ncols, G->A)) ;
+      93             :     GrB_Type etype ;
+      94             :     char atype_name [LAGRAPH_MAX_NAME_LEN] ;
+      95         483 :     LG_TRY (LAGraph_Matrix_TypeName (atype_name, G->A, msg)) ;
+      96         483 :     LG_TRY (LAGraph_TypeFromName (&etype, atype_name, msg)) ;
+      97         483 :     int etypecode = 0 ;
+      98         483 :     size_t etypesize = 0 ;
+      99         483 :     double etypeinf = INFINITY ;
+     100             : 
+     101         483 :     if (etype == GrB_INT32)
+     102             :     {
+     103         257 :         etypecode = 0 ;
+     104         257 :         etypesize = sizeof (int32_t) ;
+     105         257 :         etypeinf  = (double) INT32_MAX ;
+     106             :     }
+     107         226 :     else if (etype == GrB_INT64)
+     108             :     {
+     109          48 :         etypecode = 1 ;
+     110          48 :         etypesize = sizeof (int64_t) ;
+     111          48 :         etypeinf  = (double) INT64_MAX ;
+     112             :     }
+     113         178 :     else if (etype == GrB_UINT32)
+     114             :     {
+     115          12 :         etypecode = 2 ;
+     116          12 :         etypesize = sizeof (uint32_t) ;
+     117          12 :         etypeinf  = (double) UINT32_MAX ;
+     118             :     }
+     119         166 :     else if (etype == GrB_UINT64)
+     120             :     {
+     121          12 :         etypecode = 3 ;
+     122          12 :         etypesize = sizeof (uint64_t) ;
+     123          12 :         etypeinf  = (double) UINT64_MAX ;
+     124             :     }
+     125         154 :     else if (etype == GrB_FP32)
+     126             :     {
+     127           9 :         etypecode = 4 ;
+     128           9 :         etypesize = sizeof (float) ;
+     129           9 :         etypeinf  = INFINITY ;
+     130             :     }
+     131         145 :     else if (etype == GrB_FP64)
+     132             :     {
+     133         145 :         etypecode = 5 ;
+     134         145 :         etypesize = sizeof (double) ;
+     135         145 :         etypeinf  = INFINITY ;
+     136             :     }
+     137             : 
+     138         483 :     LG_ASSERT_MSG (etypesize > 0, GrB_NOT_IMPLEMENTED, "type not supported") ;
+     139             : 
+     140         483 :     bool print_timings = (n >= 2000) ;
+     141             : 
+     142             :     //--------------------------------------------------------------------------
+     143             :     // get the contents of the Path_Length vector
+     144             :     //--------------------------------------------------------------------------
+     145             : 
+     146         483 :     LG_TRY (LAGraph_Malloc ((void **) &path_length_in, n, sizeof (double),
+     147             :         msg)) ;
+     148         483 :     LG_TRY (LAGraph_Malloc ((void **) &reachable_in, n, sizeof (double), msg)) ;
+     149       62662 :     for (int64_t i = 0 ; i < n ; i++)
+     150             :     {
+     151             :         double t ;
+     152       62179 :         path_length_in [i] = INFINITY ;
+     153       62179 :         int info = GrB_Vector_extractElement_FP64 (&t, Path_Length, i) ;
+     154       62179 :         if (info == GrB_SUCCESS)
+     155             :         {
+     156       62179 :             path_length_in [i] = t ;
+     157             :         }
+     158       62179 :         reachable_in [i] = (path_length_in [i] < etypeinf) ;
+     159             :     }
+     160             : 
+     161             :     //--------------------------------------------------------------------------
+     162             :     // unpack the matrix in CSR form for SuiteSparse:GraphBLAS
+     163             :     //--------------------------------------------------------------------------
+     164             : 
+     165         483 :     bool iso = false ;
+     166             :     #if LAGRAPH_SUITESPARSE
+     167             :     bool jumbled ;
+     168         483 :     GRB_TRY (GxB_Matrix_unpack_CSR (G->A,
+     169             :         &Ap, &Aj, (void **) &Ax, &Ap_size, &Aj_size, &Ax_size, &iso, &jumbled,
+     170             :         NULL)) ;
+     171             :     #endif
+     172             : 
+     173             :     //--------------------------------------------------------------------------
+     174             :     // compute the SSSP of the graph, via Dijskstra's algorithm
+     175             :     //--------------------------------------------------------------------------
+     176             : 
+     177         483 :     if (print_timings)
+     178             :     {
+     179          20 :         tt = LAGraph_WallClockTime ( ) - tt ;
+     180          20 :         printf ("LG_check_sssp init  time: %g sec\n", tt) ;
+     181          20 :         tt = LAGraph_WallClockTime ( ) ;
+     182             :     }
+     183             : 
+     184             :     // initializations
+     185         483 :     LG_TRY (LAGraph_Malloc ((void **) &distance, n, sizeof (double), msg)) ;
+     186         483 :     LG_TRY (LAGraph_Malloc ((void **) &reachable, n, sizeof (bool), msg)) ;
+     187       62662 :     for (int64_t i = 0 ; i < n ; i++)
+     188             :     {
+     189       62179 :         distance [i] = INFINITY ;
+     190       62179 :         reachable [i] = false ;
+     191             :     }
+     192         483 :     distance [src] = 0 ;
+     193         483 :     reachable [src] = true ;
+     194             : 
+     195             :     #if !LAGRAPH_SUITESPARSE
+     196             :     GRB_TRY (GrB_Vector_new (&Row, GrB_FP64, n)) ;
+     197             :     LG_TRY (LAGraph_Malloc ((void **) &neighbors, n, sizeof (GrB_Index), msg)) ;
+     198             :     LG_TRY (LAGraph_Malloc ((void **) &neighbor_weights, n, sizeof (double), msg)) ;
+     199             :     LG_ASSERT (neighbors != NULL, GrB_OUT_OF_MEMORY) ;
+     200             :     LG_ASSERT (neighbor_weights != NULL, GrB_OUT_OF_MEMORY) ;
+     201             :     #endif
+     202             : 
+     203             :     // place all nodes in the heap (already in heap order)
+     204         483 :     LG_TRY (LAGraph_Malloc ((void **) &Heap, (n+1), sizeof (LG_Element), msg)) ;
+     205         483 :     LG_TRY (LAGraph_Malloc ((void **) &Iheap, n, sizeof (int64_t), msg)) ;
+     206         483 :     LG_ASSERT (Heap != NULL && Iheap != NULL, GrB_OUT_OF_MEMORY) ;
+     207         483 :     Heap [1].key = 0 ;
+     208         483 :     Heap [1].name = src ;
+     209         483 :     Iheap [src] = 1 ;
+     210         483 :     int64_t p = 2 ;
+     211       62662 :     for (int64_t i = 0 ; i < n ; i++)
+     212             :     {
+     213       62179 :         if (i != src)
+     214             :         {
+     215       61696 :             Heap [p].key = INFINITY ;
+     216       61696 :             Heap [p].name = i ;
+     217       61696 :             Iheap [i] = p ;
+     218       61696 :             p++ ;
+     219             :         }
+     220             :     }
+     221         483 :     int64_t nheap = n ;
+     222         483 :     LG_ASSERT_MSG (LG_heap_check (Heap, Iheap, n, nheap) == 0, -2000,
+     223             :         "invalid heap") ;
+     224             : 
+     225       44388 :     while (nheap > 0)
+     226             :     {
+     227             :         // extract the min element u from the top of the heap
+     228       44092 :         LG_Element e = Heap [1] ;
+     229       44092 :         int64_t u = e.name ;
+     230             : 
+     231       44092 :         double u_distance = e.key ;
+     232             :         ASSERT (distance [u] == u_distance) ;
+     233       44092 :         LG_heap_delete (1, Heap, Iheap, n, &nheap) ;
+     234             :         ASSERT (Iheap [u] == 0) ;
+     235       44092 :         reachable [u] = (u_distance < etypeinf) ;
+     236             : 
+     237       44092 :         if (n < 200)
+     238             :         {
+     239        4946 :             LG_ASSERT_MSG (LG_heap_check (Heap, Iheap, n, nheap) == 0, -2000,
+     240             :                 "invalid heap") ;
+     241             :         }
+     242             : 
+     243       44092 :         if (u_distance == INFINITY)
+     244             :         {
+     245             :             // node u is not reachable, so no other nodes in the queue
+     246             :             // are reachable either.  All work is done.
+     247         187 :             break ;
+     248             :         }
+     249             : 
+     250             :         #if LAGRAPH_SUITESPARSE
+     251             :         // directly access the indices of entries in A(u,:)
+     252       43905 :         GrB_Index degree = Ap [u+1] - Ap [u] ;
+     253       43905 :         GrB_Index *node_u_adjacency_list = Aj + Ap [u] ;
+     254       43905 :         void *weights = ((char *) Ax) + ((iso ? 0 : Ap [u]) * etypesize) ;
+     255             :         #else
+     256             :         // extract the indices of entries in A(u,:)
+     257             :         GrB_Index degree = n ;
+     258             :         GRB_TRY (GrB_Col_extract (Row, NULL, NULL, G->A, GrB_ALL, n, u,
+     259             :             GrB_DESC_T0)) ;
+     260             :         GRB_TRY (GrB_Vector_extractTuples_FP64 (neighbors, neighbor_weights,
+     261             :             &degree, Row)) ;
+     262             :         GrB_Index *node_u_adjacency_list = neighbors ;
+     263             :         double *weights = neighbor_weights ;
+     264             :         #endif
+     265             : 
+     266             :         // traverse all entries in A(u,:)
+     267      614795 :         for (int64_t k = 0 ; k < degree ; k++)
+     268             :         {
+     269             :             // consider edge (u,v) and its weight w
+     270      570890 :             int64_t v = node_u_adjacency_list [k] ;
+     271      570890 :             if (Iheap [v] == 0) continue ;  // node v already in SSSP tree
+     272             :             double w ;
+     273             :             #if LAGRAPH_SUITESPARSE
+     274      269114 :             switch (etypecode)
+     275             :             {
+     276      134179 :                 default:
+     277      134179 :                 case 0: w = (( int32_t *) weights) [iso ? 0 : k] ; break ;
+     278         312 :                 case 1: w = (( int64_t *) weights) [iso ? 0 : k] ; break ;
+     279          51 :                 case 2: w = ((uint32_t *) weights) [iso ? 0 : k] ; break ;
+     280          51 :                 case 3: w = ((uint64_t *) weights) [iso ? 0 : k] ; break ;
+     281          90 :                 case 4: w = (( float   *) weights) [iso ? 0 : k] ; break ;
+     282      134431 :                 case 5: w = (( double  *) weights) [iso ? 0 : k] ; break ;
+     283             :             }
+     284             :             #else
+     285             :             w = weights [iso ? 0 : k] ;
+     286             :             #endif
+     287             : 
+     288      269114 :             LG_ASSERT_MSG (w > 0, -2002, "invalid graph (weights must be > 0)");
+     289      269114 :             double new_distance = u_distance + w ;
+     290      269114 :             if (distance [v] > new_distance)
+     291             :             {
+     292             :                 // reduce the key of node v
+     293       60199 :                 distance [v] = new_distance ;
+     294             :                 // parent [v] = u ;
+     295       60199 :                 int64_t p = Iheap [v] ;
+     296       60199 :                 LG_ASSERT_MSG (Heap [p].name == v, -2000, "invalid heap") ;
+     297       60199 :                 LG_heap_decrease_key (p, new_distance, Heap, Iheap, n, nheap) ;
+     298             :             }
+     299             :         }
+     300             : 
+     301       43905 :         if (n < 200)
+     302             :         {
+     303        4771 :             LG_ASSERT_MSG (LG_heap_check (Heap, Iheap, n, nheap) == 0, -2000,
+     304             :                 "invalid heap") ;
+     305             :         }
+     306             :     }
+     307             : 
+     308         483 :     if (print_timings)
+     309             :     {
+     310          20 :         tt = LAGraph_WallClockTime ( ) - tt ;
+     311          20 :         printf ("LG_check_sssp time: %g sec\n", tt) ;
+     312          20 :         tt = LAGraph_WallClockTime ( ) ;
+     313             :     }
+     314             : 
+     315             :     //--------------------------------------------------------------------------
+     316             :     // repack the matrix in CSR form for SuiteSparse:GraphBLAS
+     317             :     //--------------------------------------------------------------------------
+     318             : 
+     319             :     #if LAGRAPH_SUITESPARSE
+     320         483 :     GRB_TRY (GxB_Matrix_pack_CSR (G->A,
+     321             :         &Ap, &Aj, (void **) &Ax, Ap_size, Aj_size, Ax_size, iso, jumbled,
+     322             :         NULL)) ;
+     323             :     #endif
+     324             : 
+     325             :     //--------------------------------------------------------------------------
+     326             :     // check the distance of each node
+     327             :     //--------------------------------------------------------------------------
+     328             : 
+     329       62662 :     for (int64_t i = 0 ; i < n ; i++)
+     330             :     {
+     331       62179 :         bool ok = true ;
+     332       62179 :         double err = 0 ;
+     333       62179 :         if (isinf (distance [i]))
+     334             :         {
+     335       18274 :             ok = (path_length_in [i] == etypeinf || isinf (path_length_in [i]));
+     336             :         }
+     337             :         else
+     338             :         {
+     339       43905 :             err = fabs (path_length_in [i] - distance [i]) ;
+     340       43905 :             double d = LAGRAPH_MAX (path_length_in [i], distance [i]) ;
+     341       43905 :             if (err > 0) err = err / d ;
+     342       43905 :             ok = (err < 1e-5) ;
+     343             :         }
+     344       62179 :         LG_ASSERT_MSG (ok, -2001, "invalid path length") ;
+     345             :     }
+     346             : 
+     347             :     //--------------------------------------------------------------------------
+     348             :     // check the reach
+     349             :     //--------------------------------------------------------------------------
+     350             : 
+     351       62662 :     for (int64_t i = 0 ; i < n ; i++)
+     352             :     {
+     353       62179 :         bool ok = (reachable [i] == reachable_in [i]) ;
+     354             :         #if 0
+     355             :         printf ("reach [%ld]: %d %d\n", i, reachable [i], reachable_in [i]) ;
+     356             :         if (!ok)
+     357             :         {
+     358             :             printf ("Hey! source %ld\n", src) ;
+     359             :             GxB_print (G->A, 3) ;
+     360             :             GxB_print (Path_Length, 3) ;
+     361             :             for (int64_t i = 0 ; i < n ; i++)
+     362             :             {
+     363             :                 printf ("check [%ld]: reach %d %d distance %g\n", i,
+     364             :                     reachable [i], reachable_in [i], distance [i]) ;
+     365             :             }
+     366             : 
+     367             :         }
+     368             :         #endif
+     369       62179 :         LG_ASSERT_MSG (ok, -2001, "invalid reach") ;
+     370             :     }
+     371             : 
+     372             :     //--------------------------------------------------------------------------
+     373             :     // free workspace and return result
+     374             :     //--------------------------------------------------------------------------
+     375             : 
+     376         483 :     LG_FREE_WORK ;
+     377             : 
+     378         483 :     if (print_timings)
+     379             :     {
+     380          20 :         tt = LAGraph_WallClockTime ( ) - tt ;
+     381          20 :         printf ("LG_check_sssp check time: %g sec\n", tt) ;
+     382             :     }
+     383         483 :     return (GrB_SUCCESS) ;
+     384             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/LG_check_tri.c.func-sort-c.html b/src/test/LG_check_tri.c.func-sort-c.html new file mode 100644 index 0000000000..4bb22adb84 --- /dev/null +++ b/src/test/LG_check_tri.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/LG_check_tri.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - LG_check_tri.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3535100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_check_tri143
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/LG_check_tri.c.func.html b/src/test/LG_check_tri.c.func.html new file mode 100644 index 0000000000..7df19c585f --- /dev/null +++ b/src/test/LG_check_tri.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/LG_check_tri.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - LG_check_tri.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3535100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_check_tri143
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/LG_check_tri.c.gcov.html b/src/test/LG_check_tri.c.gcov.html new file mode 100644 index 0000000000..3aade73498 --- /dev/null +++ b/src/test/LG_check_tri.c.gcov.html @@ -0,0 +1,215 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/LG_check_tri.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - LG_check_tri.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3535100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LG_check_tri: compute the number of triangles in a graph (simple method)
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // A very slow, bare-bones triangle count using a parallel dot-product method.
+      19             : // Computes the sum(sum((A'*A).*A)), in MATLAB notation, where A is symmetric
+      20             : // and treated as binary (only the structure is used).  Diagonal entries are
+      21             : // ignored.  In GraphBLAS notation, C{A} = A'*A followed by reduce(C) to scalar.
+      22             : // This method is for testing only, to check the result of other, faster
+      23             : // methods.  Do not benchmark this method; it is slow and simple by design.
+      24             : 
+      25             : #define LG_FREE_ALL                         \
+      26             : {                                           \
+      27             :     LAGraph_Free ((void **) &Ap, NULL) ;    \
+      28             :     LAGraph_Free ((void **) &Aj, NULL) ;    \
+      29             :     LAGraph_Free ((void **) &Ax, NULL) ;    \
+      30             : }
+      31             : 
+      32             : #include "LG_internal.h"
+      33             : #include "LG_test.h"
+      34             : 
+      35             : //------------------------------------------------------------------------------
+      36             : // LG_check_tri
+      37             : //------------------------------------------------------------------------------
+      38             : 
+      39             : // Since this method does not modify G->A, it can be tested with LG_BRUTAL.
+      40             : // See test_TriangleCount for a brutal memory test of this method.
+      41             : 
+      42         143 : int LG_check_tri        // -1 if out of memory, 0 if successful
+      43             : (
+      44             :     // output
+      45             :     uint64_t *ntri,     // # of triangles in A
+      46             :     // input
+      47             :     LAGraph_Graph G,    // the structure of G->A must be symmetric
+      48             :     char *msg
+      49             : )
+      50             : {
+      51             : 
+      52             :     //--------------------------------------------------------------------------
+      53             :     // check inputs
+      54             :     //--------------------------------------------------------------------------
+      55             : 
+      56         143 :     LG_CLEAR_MSG ;
+      57             : 
+      58         143 :     GrB_Index *Ap = NULL, *Aj = NULL, *Ai = NULL ;
+      59         143 :     void *Ax = NULL ;
+      60             :     GrB_Index Ap_size, Aj_size, Ax_size, n, ncols, Ap_len, Aj_len, Ax_len ;
+      61         143 :     LG_ASSERT (ntri != NULL, GrB_NULL_POINTER) ;
+      62         143 :     LG_TRY (LAGraph_CheckGraph (G, msg)) ;
+      63         143 :     LG_ASSERT (G->nself_edges == 0, LAGRAPH_NO_SELF_EDGES_ALLOWED) ;
+      64         143 :     LG_ASSERT_MSG ((G->kind == LAGraph_ADJACENCY_UNDIRECTED ||
+      65             :        (G->kind == LAGraph_ADJACENCY_DIRECTED &&
+      66             :         G->is_symmetric_structure == LAGraph_TRUE)),
+      67             :         LAGRAPH_SYMMETRIC_STRUCTURE_REQUIRED,
+      68             :         "G->A must be known to be symmetric") ;
+      69         143 :     GRB_TRY (GrB_Matrix_nrows (&n, G->A)) ;
+      70         143 :     GRB_TRY (GrB_Matrix_ncols (&ncols, G->A)) ;
+      71             : 
+      72             :     //--------------------------------------------------------------------------
+      73             :     // export the matrix in CSR form
+      74             :     //--------------------------------------------------------------------------
+      75             : 
+      76             :     size_t typesize ;
+      77         143 :     LG_TRY (LG_check_export (G, &Ap, &Aj, &Ax, &Ap_len, &Aj_len, &Ax_len,
+      78             :         &typesize, msg)) ;
+      79             : 
+      80             :     //--------------------------------------------------------------------------
+      81             :     // compute the # of triangles (each triangle counted 6 times)
+      82             :     //--------------------------------------------------------------------------
+      83             : 
+      84          37 :     int64_t ntriangles = 0 ;
+      85          37 :     Ai = Aj ;       // pretend A is symmetric and in CSC format instead
+      86             : 
+      87             :     // masked dot-product method
+      88             :     int64_t j;
+      89             :     #if !defined ( COVERAGE )
+      90             :     #pragma omp parallel for reduction(+:ntriangles) schedule(dynamic,1024)
+      91             :     #endif
+      92       12987 :     for (j = 0 ; j < n ; j++)
+      93             :     {
+      94             :         // for each entry in the lower triangular part of A
+      95      367098 :         for (int64_t p = Ap [j] ; p < Ap [j+1] ; p++)
+      96             :         {
+      97      354148 :             const int64_t i = Ai [p] ;
+      98      354148 :             if (i > j)
+      99             :             {
+     100             :                 // ntriangles += A(:,i)' * A(:,j)
+     101      177074 :                 int64_t p1 = Ap [i] ;
+     102      177074 :                 int64_t p1_end = Ap [i+1] ;
+     103      177074 :                 int64_t p2 = Ap [j] ;
+     104      177074 :                 int64_t p2_end = Ap [j+1] ;
+     105    11681606 :                 while (p1 < p1_end && p2 < p2_end)
+     106             :                 {
+     107    11504532 :                     int64_t i1 = Ai [p1] ;
+     108    11504532 :                     int64_t i2 = Ai [p2] ;
+     109    11504532 :                     if (i1 < i2)
+     110             :                     {
+     111             :                         // A(i1,i) appears before A(i2,j)
+     112     3055392 :                         p1++ ;
+     113             :                     }
+     114     8449140 :                     else if (i2 < i1)
+     115             :                     {
+     116             :                         // A(i2,j) appears before A(i1,i)
+     117     4316361 :                         p2++ ;
+     118             :                     }
+     119             :                     else // i1 == i2 == k
+     120             :                     {
+     121             :                         // A(k,i) and A(k,j) are the next entries to merge
+     122     4132779 :                         ntriangles++ ;
+     123     4132779 :                         p1++ ;
+     124     4132779 :                         p2++ ;
+     125             :                     }
+     126             :                 }
+     127             :             }
+     128             :         }
+     129             :     }
+     130          37 :     ntriangles = ntriangles / 3 ;
+     131             : 
+     132             :     //--------------------------------------------------------------------------
+     133             :     // free workspace and return result
+     134             :     //--------------------------------------------------------------------------
+     135             : 
+     136          37 :     LG_FREE_ALL ;
+     137          37 :     (*ntri) = ntriangles ;
+     138          37 :     return (GrB_SUCCESS) ;
+     139             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/LG_check_vector.c.func-sort-c.html b/src/test/LG_check_vector.c.func-sort-c.html new file mode 100644 index 0000000000..605008da0e --- /dev/null +++ b/src/test/LG_check_vector.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/LG_check_vector.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - LG_check_vector.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:99100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_check_vector2219
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/LG_check_vector.c.func.html b/src/test/LG_check_vector.c.func.html new file mode 100644 index 0000000000..d5aae032dc --- /dev/null +++ b/src/test/LG_check_vector.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/LG_check_vector.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - LG_check_vector.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:99100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_check_vector2219
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/LG_check_vector.c.gcov.html b/src/test/LG_check_vector.c.gcov.html new file mode 100644 index 0000000000..0716154fbd --- /dev/null +++ b/src/test/LG_check_vector.c.gcov.html @@ -0,0 +1,124 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/LG_check_vector.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - LG_check_vector.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:99100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph/src/test/LG_check_vector: extract contents of a vector, for testing
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // This is slow, for testing only.
+      19             : // See src/test/test_vector for the brutal test.
+      20             : 
+      21             : #include "LG_internal.h"
+      22             : #include "LG_test.h"
+      23             : 
+      24        2219 : int LG_check_vector
+      25             : (
+      26             :     int64_t *x,         // x (0:n-1) = X (0:n-1), of type int64_t
+      27             :     GrB_Vector X,       // vector of size n
+      28             :     int64_t n,
+      29             :     int64_t missing     // value to assign to x(i) if X(i) is not present
+      30             : )
+      31             : {
+      32             : 
+      33      458629 :     for (int64_t i = 0 ; i < n ; i++)
+      34             :     {
+      35             :         int64_t t ;
+      36      456419 :         int info = GrB_Vector_extractElement_INT64 (&t, X, i) ;
+      37      456419 :         x [i] = missing ;
+      38      456419 :         if (info == GrB_SUCCESS)
+      39             :         {
+      40      433322 :             x [i] = t ;
+      41             :         }
+      42       23097 :         else if (info != GrB_NO_VALUE)
+      43             :         {
+      44           9 :             return (info) ;
+      45             :         }
+      46             :     }
+      47        2210 :     return (GrB_SUCCESS) ;
+      48             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/LG_heap.h.func-sort-c.html b/src/test/LG_heap.h.func-sort-c.html new file mode 100644 index 0000000000..5d93b56322 --- /dev/null +++ b/src/test/LG_heap.h.func-sort-c.html @@ -0,0 +1,92 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/LG_heap.h - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - LG_heap.h (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:7878100.0 %
Date:2024-08-29 20:08:04Functions:55100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_heap_check10200
LG_iheap_check10200
LG_heap_delete44092
LG_heapify44092
LG_heap_decrease_key60199
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/LG_heap.h.func.html b/src/test/LG_heap.h.func.html new file mode 100644 index 0000000000..5b1d1fea9c --- /dev/null +++ b/src/test/LG_heap.h.func.html @@ -0,0 +1,92 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/LG_heap.h - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - LG_heap.h (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:7878100.0 %
Date:2024-08-29 20:08:04Functions:55100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_heap_check10200
LG_heap_decrease_key60199
LG_heap_delete44092
LG_heapify44092
LG_iheap_check10200
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/LG_heap.h.gcov.html b/src/test/LG_heap.h.gcov.html new file mode 100644 index 0000000000..6efd7420f5 --- /dev/null +++ b/src/test/LG_heap.h.gcov.html @@ -0,0 +1,505 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/LG_heap.h + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - LG_heap.h (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:7878100.0 %
Date:2024-08-29 20:08:04Functions:55100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LG_heap: a Heap data structure and its operations
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // The Heap is an array of LG_Elements: Heap [1..nheap].  Each entry in the
+      19             : // Heap is a LG_Element, with a key and name.  LG_Element must be defined
+      20             : // by the including file.  For example:
+      21             : 
+      22             : /*
+      23             :     typedef int64_t LG_key_t ;
+      24             :     typedef struct
+      25             :     {
+      26             :         int64_t name ;
+      27             :         LG_key_t key ;
+      28             :     }
+      29             :     LG_Element ;
+      30             :     #include "LG_heap.h"
+      31             : */
+      32             : 
+      33             : #ifndef LG_HEAP_H
+      34             : #define LG_HEAP_H
+      35             : 
+      36             : #undef  LG_FREE_ALL
+      37             : #define LG_FREE_ALL ;
+      38             : 
+      39             : // These methods assume the caller allocates all memory, so no brutal memory
+      40             : // test is needed.
+      41             : 
+      42             : //------------------------------------------------------------------------------
+      43             : // LG_iheap_check: make sure Iheap is correct
+      44             : //------------------------------------------------------------------------------
+      45             : 
+      46             : // Ensure that e == Heap [p] implies p == Iheap [e.name] for all entries
+      47             : // in the heap.  Also ensure that e.name is in the range 0:n-1.
+      48             : 
+      49       10200 : static inline int LG_iheap_check
+      50             : (
+      51             :     // input:
+      52             :     const LG_Element *restrict Heap,    // Heap [1..nheap], not modified
+      53             :     const int64_t *restrict Iheap,      // Iheap [0..n-1], not modified
+      54             :     const int64_t n,                    // element names are in range 0:n-1
+      55             :     const int64_t nheap                 // the number of nodes in the Heap
+      56             : )
+      57             : {
+      58             : 
+      59       10200 :     char *msg = NULL ;
+      60       10200 :     LG_ASSERT_MSG (Heap != NULL && Iheap != NULL && nheap >= 0 && n >= 0, -2000,
+      61             :         "Heap is invalid") ;
+      62             : 
+      63             :     // check all entries in the heap
+      64      225824 :     for (int64_t p = 1 ; p <= nheap ; p++)
+      65             :     {
+      66      215624 :         LG_Element e = Heap [p] ;
+      67      215624 :         int64_t name = e.name ;
+      68      215624 :         LG_ASSERT_MSG (name >= 0 && name < n && p == Iheap [name], -2000,
+      69             :             "Heap is invalid") ;
+      70             :     }
+      71             : 
+      72             :     // check all objects
+      73      383307 :     for (int64_t name = 0 ; name < n ; name++)
+      74             :     {
+      75      373107 :         int64_t p = Iheap [name] ;
+      76      373107 :         if (p <= 0)
+      77             :         {
+      78             :             // object with this name is not in the heap
+      79             :         }
+      80             :         else
+      81             :         {
+      82      215624 :             LG_ASSERT_MSG (p <= nheap, -2000, "position of object is invalid") ;
+      83             :             // object with this name is in the heap at position p
+      84      215624 :             LG_Element e = Heap [p] ;
+      85      215624 :             LG_ASSERT_MSG (e.name == name, -2000, "Heap is invalid") ;
+      86             :         }
+      87             :     }
+      88             : 
+      89             :     // Heap and Iheap are consistent
+      90       10200 :     return (GrB_SUCCESS) ;
+      91             : }
+      92             : 
+      93             : //------------------------------------------------------------------------------
+      94             : // LG_heap_check: make sure the min-heap property holds for the whole Heap
+      95             : //------------------------------------------------------------------------------
+      96             : 
+      97             : // Check the entire Heap to see if it has the min-heap property:  for all nodes
+      98             : // in the Heap, the key of a node must less than or equal to the keys of its
+      99             : // children  (duplicate keys may appear).  An empty Heap or a Heap of size 1
+     100             : // always satisfies the min-heap property, but nheap < 0 is invalid.  This
+     101             : // function is for assertions only.
+     102             : 
+     103       10200 : static inline int LG_heap_check
+     104             : (
+     105             :     // input:
+     106             :     const LG_Element *restrict Heap,    // Heap [1..nheap], not modified
+     107             :     const int64_t *restrict Iheap,      // Iheap [0..n-1], not modified
+     108             :     const int64_t n,                    // element names are in range 0:n-1
+     109             :     const int64_t nheap                 // the number of nodes in the Heap
+     110             : )
+     111             : {
+     112             : 
+     113       10200 :     char *msg = NULL ;
+     114       10200 :     LG_ASSERT_MSG (Heap != NULL && Iheap != NULL && nheap >= 0 && n >= 0, -2000,
+     115             :         "Heap is invalid") ;
+     116             : 
+     117             : #if 0
+     118             :     // dump the heap
+     119             :     for (int64_t p = 1 ; p <= nheap ; p++)
+     120             :     {
+     121             :         printf ("Heap [%ld]: key %ld name: %ld\n", p, Heap [p].key,
+     122             :             Heap [p].name) ;
+     123             :         int64_t pleft  = 2*p ;          // left child of node p
+     124             :         int64_t pright = pleft + 1 ;    // right child of node p
+     125             :         if (pleft <= nheap)
+     126             :         {
+     127             :             printf ("     left  child: %ld (key %ld, name %ld)\n",
+     128             :                 pleft, Heap [pleft].key, Heap [pleft].name) ;
+     129             :         }
+     130             :         if (pright <= nheap)
+     131             :         {
+     132             :             printf ("     right child: %ld (key %ld, name %ld)\n",
+     133             :                 pright, Heap [pright].key, Heap [pright].name) ;
+     134             :         }
+     135             :         printf ("\n") ;
+     136             :     }
+     137             : #endif
+     138             : 
+     139             :     // nodes nheap/2 ... nheap have no children, so no need to check them
+     140      115535 :     for (int64_t p = 1 ; p <= nheap / 2 ; p++)
+     141             :     {
+     142             : 
+     143             :         // consider node p.  Its key must be <= the key of both its children.
+     144             : 
+     145      105335 :         int64_t pleft  = 2*p ;          // left child of node p
+     146      105335 :         int64_t pright = pleft + 1 ;    // right child of node p
+     147             : 
+     148      105335 :         LG_ASSERT_MSG (! (pleft <= nheap && Heap [p].key > Heap [pleft].key),
+     149             :             -2000, "the min-heap property is not satisfied") ;
+     150             : 
+     151      105335 :         LG_ASSERT_MSG (! (pright <= nheap && Heap [p].key > Heap [pright].key),
+     152             :             -2000, "the min-heap property is not satisfied") ;
+     153             :     }
+     154             : 
+     155             :     // Heap satisfies the min-heap property; also check Iheap
+     156       10200 :     return (LG_iheap_check (Heap, Iheap, n, nheap)) ;
+     157             : }
+     158             : 
+     159             : //------------------------------------------------------------------------------
+     160             : // LG_heapify: enforce the min-heap property of a node
+     161             : //------------------------------------------------------------------------------
+     162             : 
+     163             : // Heapify starting at node p in the Heap.  On input, the Heap rooted at node p
+     164             : // satisfies the min-heap property, except for Heap [p] itself.  On output, all
+     165             : // of the Heap rooted at node p satisfies the min-heap property.
+     166             : 
+     167       44092 : static inline void LG_heapify
+     168             : (
+     169             :     int64_t p,                      // node that needs to be heapified
+     170             :     LG_Element *restrict Heap,      // Heap [1..nheap]
+     171             :     int64_t *restrict Iheap,        // Iheap [0..n-1]
+     172             :     const int64_t n,                // max element name
+     173             :     const int64_t nheap             // the number of nodes in the Heap
+     174             : )
+     175             : {
+     176             : 
+     177             :     //--------------------------------------------------------------------------
+     178             :     // check inputs and check for quick return
+     179             :     //--------------------------------------------------------------------------
+     180             : 
+     181             :     ASSERT (Heap != NULL && Iheap != NULL) ;
+     182             : 
+     183       44092 :     if (p > nheap / 2 || nheap <= 1)
+     184             :     {
+     185             :         // nothing to do.  p has no children in the Heap.
+     186             :         // Also safely do nothing if p is outside the Heap (p > nheap).
+     187         622 :         return ;
+     188             :     }
+     189             : 
+     190             :     //--------------------------------------------------------------------------
+     191             :     // get the element to heapify
+     192             :     //--------------------------------------------------------------------------
+     193             : 
+     194             :     // Get the element e at node p in the Heap; the one that needs heapifying.
+     195       43470 :     LG_Element e = Heap [p] ;
+     196             : 
+     197             :     // There is now a "hole" at Heap [p], with no element in it.
+     198             : 
+     199             :     //--------------------------------------------------------------------------
+     200             :     // heapify
+     201             :     //--------------------------------------------------------------------------
+     202             : 
+     203             :     while (true)
+     204      233225 :     {
+     205             : 
+     206             :         //----------------------------------------------------------------------
+     207             :         // consider node p in the Heap
+     208             :         //----------------------------------------------------------------------
+     209             : 
+     210             :         // Heap [p] is the "hole" in the Heap
+     211             : 
+     212      276695 :         int64_t pleft  = 2*p ;          // left child of node p
+     213      276695 :         int64_t pright = pleft + 1 ;    // right child of node p
+     214             : 
+     215      276695 :         if (pright <= nheap)
+     216             :         {
+     217             : 
+     218             :             //------------------------------------------------------------------
+     219             :             // both left and right children are in the Heap
+     220             :             //------------------------------------------------------------------
+     221             : 
+     222      267934 :             LG_Element eleft  = Heap [pleft] ;
+     223      267934 :             LG_Element eright = Heap [pright] ;
+     224      267934 :             if (eleft.key < eright.key)
+     225             :             {
+     226             :                 // left node has a smaller key than the right node
+     227      119095 :                 if (e.key > eleft.key)
+     228             :                 {
+     229             :                     // key of element e is bigger than the left child of p, so
+     230             :                     // bubble up the left child into the hole at Heap [p] and
+     231             :                     // continue down the left child.  The hole moves to node
+     232             :                     // pleft.
+     233      118616 :                     Heap [p] = eleft ;
+     234      118616 :                     Iheap [eleft.name] = p ;
+     235      118616 :                     p = pleft ;
+     236             :                 }
+     237             :                 else
+     238             :                 {
+     239             :                     // done!  key of element e is is smaller than the left
+     240             :                     // child of p; place e in the hole at p, and we're done.
+     241         479 :                     Heap [p] = e ;
+     242         479 :                     Iheap [e.name] = p ;
+     243       34709 :                     return ;
+     244             :                 }
+     245             :             }
+     246             :             else
+     247             :             {
+     248             :                 // right node has a smaller key than the left node
+     249      148839 :                 if (e.key > eright.key)
+     250             :                 {
+     251             :                     // key of element e is bigger than the right child of p, so
+     252             :                     // bubble up the right child into hole at Heap [p] and
+     253             :                     // continue down the right child.  The hole moves to node
+     254             :                     // pright.
+     255      114609 :                     Heap [p] = eright ;
+     256      114609 :                     Iheap [eright.name] = p ;
+     257      114609 :                     p = pright ;
+     258             :                 }
+     259             :                 else
+     260             :                 {
+     261             :                     // done!  key of element e is is smaller than the right
+     262             :                     // child of p; place e in the hole at p, and we're done.
+     263       34230 :                     Heap [p] = e ;
+     264       34230 :                     Iheap [e.name] = p ;
+     265       34230 :                     return ;
+     266             :                 }
+     267             :             }
+     268             :         }
+     269             :         else
+     270             :         {
+     271             : 
+     272             :             //------------------------------------------------------------------
+     273             :             // right child is not in the Heap, see if left child is in the Heap
+     274             :             //------------------------------------------------------------------
+     275             : 
+     276        8761 :             if (pleft <= nheap)
+     277             :             {
+     278             :                 // left child is in the Heap; check its key
+     279        1185 :                 LG_Element eleft = Heap [pleft] ;
+     280        1185 :                 if (e.key > eleft.key)
+     281             :                 {
+     282             :                     // key of element e is bigger than the left child of p, so
+     283             :                     // bubble up the left child into the hole at Heap [p] and
+     284             :                     // continue down the left child.  The hole moves to node
+     285             :                     // pleft.
+     286         289 :                     Heap [p] = eleft ;
+     287         289 :                     Iheap [eleft.name] = p ;
+     288         289 :                     p = pleft ;
+     289             :                 }
+     290             :             }
+     291             : 
+     292             :             //------------------------------------------------------------------
+     293             :             // node p is a hole, and it has no children
+     294             :             //------------------------------------------------------------------
+     295             : 
+     296             :             // put e in the hole, and we're done
+     297        8761 :             Heap [p] = e ;
+     298        8761 :             Iheap [e.name] = p ;
+     299        8761 :             return ;
+     300             :         }
+     301             :     }
+     302             : }
+     303             : 
+     304             : //------------------------------------------------------------------------------
+     305             : // LG_heap_build: construct a Heap
+     306             : //------------------------------------------------------------------------------
+     307             : 
+     308             : // On input, the Heap [1..nheap] may not satisfy the min-heap property, but
+     309             : // Iheap must already be initialized.
+     310             : // If e = Heap [p], then Iheap [e.name] = p must hold.
+     311             : 
+     312             : // On output, the elements have been rearranged so that it satisfies the
+     313             : // heap property.
+     314             : 
+     315             : static inline void LG_heap_build
+     316             : (
+     317             :     LG_Element *restrict Heap,      // Heap [1..nheap]
+     318             :     int64_t *restrict Iheap,        // Iheap [0..n-1]
+     319             :     const int64_t n,                // max element name
+     320             :     const int64_t nheap             // the number of nodes in the Heap
+     321             : )
+     322             : {
+     323             : 
+     324             :     //--------------------------------------------------------------------------
+     325             :     // check inputs
+     326             :     //--------------------------------------------------------------------------
+     327             : 
+     328             :     ASSERT (Heap != NULL && nheap >= 0) ;
+     329             :     ASSERT (LG_iheap_check (Heap, Iheap, n, nheap)) ;
+     330             : 
+     331             :     //--------------------------------------------------------------------------
+     332             :     // build the Heap
+     333             :     //--------------------------------------------------------------------------
+     334             : 
+     335             :     for (int64_t p = nheap / 2 ; p >= 1 ; p--)
+     336             :     {
+     337             :         LG_heapify (p, Heap, Iheap, n, nheap) ;
+     338             :     }
+     339             : 
+     340             :     //--------------------------------------------------------------------------
+     341             :     // check result
+     342             :     //--------------------------------------------------------------------------
+     343             : 
+     344             :     // Heap [1..nheap] now satisfies the min-heap property
+     345             :     ASSERT (LG_heap_check (Heap, Iheap, n, nheap)) ;
+     346             : }
+     347             : 
+     348             : //------------------------------------------------------------------------------
+     349             : // LG_heap_delete: delete an element in the middle of a Heap
+     350             : //------------------------------------------------------------------------------
+     351             : 
+     352       44092 : static inline void LG_heap_delete
+     353             : (
+     354             :     int64_t p,                      // node that needs to be deleted
+     355             :     LG_Element *restrict Heap,      // Heap [1..nheap]
+     356             :     int64_t *restrict Iheap,        // Iheap [0..n-1]
+     357             :     const int64_t n,                // max element name
+     358             :     int64_t *restrict nheap         // the number of nodes in the Heap;
+     359             :                                     // decremented on output
+     360             : )
+     361             : {
+     362             : 
+     363             :     //--------------------------------------------------------------------------
+     364             :     // check inputs
+     365             :     //--------------------------------------------------------------------------
+     366             : 
+     367             :     ASSERT (Heap != NULL && Iheap != NULL && (*nheap) >= 0) ;
+     368             :     ASSERT (p >= 1 && p <= (*nheap)) ;
+     369             : 
+     370             :     //--------------------------------------------------------------------------
+     371             :     // delete node p from the Heap
+     372             :     //--------------------------------------------------------------------------
+     373             : 
+     374             :     // move the last node to node p and decrement the # of nodes in the Heap
+     375       44092 :     LG_Element elast = Heap [*nheap] ;  // last node in the heap
+     376       44092 :     LG_Element edel  = Heap [p] ;       // element to delete from the heap
+     377       44092 :     Heap [p] = elast ;              // move last node in the heap to position p
+     378       44092 :     Iheap [elast.name] = p ;        // elast has been moved to position p
+     379       44092 :     Iheap [edel.name] = 0 ;         // edel is no longer in the heap
+     380       44092 :     (*nheap)-- ;                    // one less entry in the heap
+     381             : 
+     382             :     // heapify node p (safely does nothing if node p was the one just deleted)
+     383       44092 :     LG_heapify (p, Heap, Iheap, n, (*nheap)) ;
+     384       44092 : }
+     385             : 
+     386             : //------------------------------------------------------------------------------
+     387             : // LG_heap_decrease_key: decrease the key of an entry in the heap
+     388             : //------------------------------------------------------------------------------
+     389             : 
+     390       60199 : static inline void LG_heap_decrease_key
+     391             : (
+     392             :     int64_t p,                      // entry to modify in the heap
+     393             :     const LG_key_t new_key,         // new key value of Heap [p]
+     394             :     LG_Element *restrict Heap,      // Heap [1..nheap]
+     395             :     int64_t *restrict Iheap,        // Iheap [0..n-1]
+     396             :     const int64_t n,                // max element name
+     397             :     const int64_t nheap             // the number of nodes in the Heap
+     398             : )
+     399             : {
+     400             :     ASSERT (Heap != NULL && Iheap != NULL) ;
+     401             :     ASSERT (p >= 1 && p < nheap) ;
+     402             :     ASSERT (new_key < Heap [p].key) ;
+     403             : 
+     404             : //  printf ("Decreasing Heap [%ld] = name: %ld key: from %ld to %ld\n",
+     405             : //      p, Heap [p].name, Heap [p].key, new_key) ;
+     406             : 
+     407       60199 :     Heap [p].key = new_key ;
+     408       60199 :     int64_t parent = p/2 ;
+     409             : 
+     410      187582 :     while (p > 1 && Heap [parent].key > Heap [p].key)
+     411             :     {
+     412             :         // swap Heap [p] and Heap [parent]
+     413             : //      printf ("swap positions %ld and %ld\n", p, parent) ;
+     414             : 
+     415      127383 :         LG_Element e = Heap [p] ;
+     416      127383 :         Heap [p] = Heap [parent] ;
+     417      127383 :         Heap [parent] = e ;
+     418             : 
+     419             :         // update the inverse heap
+     420      127383 :         Iheap [Heap [p].name] = p ;
+     421      127383 :         Iheap [Heap [parent].name] = parent ;
+     422             : 
+     423             :         // advance up to the parent
+     424      127383 :         p = parent ;
+     425      127383 :         parent = p/2 ;
+     426             :     }
+     427       60199 : }
+     428             : 
+     429             : #endif
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/index-sort-f.html b/src/test/index-sort-f.html new file mode 100644 index 0000000000..c97e1ac2f5 --- /dev/null +++ b/src/test/index-sort-f.html @@ -0,0 +1,543 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/testHitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:41094109100.0 %
Date:2024-08-29 20:08:04Functions:162162100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
LG_brutal_teardown.c +
100.0%
+
100.0 %4 / 4100.0 %1 / 1
LG_check_bfs.c +
100.0%
+
100.0 %71 / 71100.0 %1 / 1
LG_brutal_setup.c +
100.0%
+
100.0 %8 / 8100.0 %1 / 1
LG_check_cc.c +
100.0%
+
100.0 %63 / 63100.0 %1 / 1
test_NumThreads.c +
100.0%
+
100.0 %28 / 28100.0 %1 / 1
test_Init.c +
100.0%
+
100.0 %25 / 25100.0 %1 / 1
LG_check_vector.c +
100.0%
+
100.0 %9 / 9100.0 %1 / 1
LG_check_tri.c +
100.0%
+
100.0 %35 / 35100.0 %1 / 1
test_Malloc.c +
100.0%
+
100.0 %46 / 46100.0 %1 / 1
LG_check_sssp.c +
100.0%
+
100.0 %135 / 135100.0 %1 / 1
test_WallClockTime.c +
100.0%
+
100.0 %12 / 12100.0 %1 / 1
test_acutest.c +
100.0%
+
100.0 %4 / 4100.0 %1 / 1
test_Init_errors.c +
100.0%
+
100.0 %11 / 11100.0 %1 / 1
test_Multiply_size_t.c +
100.0%
+
100.0 %12 / 12100.0 %1 / 1
LG_check_export.c +
100.0%
+
100.0 %59 / 59100.0 %1 / 1
test_fopen.c +
100.0%
+
100.0 %13 / 13100.0 %2 / 2
test_export.c +
100.0%
+
100.0 %80 / 80100.0 %2 / 2
test_Xinit.c +
100.0%
+
100.0 %76 / 76100.0 %2 / 2
test_Vector_Print.c +
100.0%
+
100.0 %142 / 142100.0 %2 / 2
test_Type.c +
100.0%
+
100.0 %94 / 94100.0 %2 / 2
test_PageRank.c +
100.0%
+
100.0 %97 / 97100.0 %2 / 2
test_vector.c +
100.0%
+
100.0 %39 / 39100.0 %2 / 2
test_Betweenness.c +
100.0%
+
100.0 %72 / 72100.0 %3 / 3
test_DeleteCached.c +
100.0%
+
100.0 %82 / 82100.0 %4 / 4
test_ConnectedComponents.c +
100.0%
+
100.0 %115 / 115100.0 %4 / 4
test_Cached_SymmetricStructure.c +
100.0%
+
100.0 %79 / 79100.0 %4 / 4
test_SingleSourceShortestPath.c +
100.0%
+
100.0 %225 / 225100.0 %4 / 4
LG_brutal_malloc.c +
100.0%
+
100.0 %29 / 29100.0 %4 / 4
test_KindName.c +
100.0%
+
100.0 %24 / 24100.0 %4 / 4
test_Cached_NDiag.c +
100.0%
+
100.0 %45 / 45100.0 %4 / 4
test_Cached_AT.c +
100.0%
+
100.0 %76 / 76100.0 %4 / 4
test_CheckGraph.c +
100.0%
+
100.0 %136 / 136100.0 %5 / 5
test_New.c +
100.0%
+
100.0 %67 / 67100.0 %5 / 5
LG_heap.h +
100.0%
+
100.0 %78 / 78100.0 %5 / 5
test_SampleDegree.c +
100.0%
+
100.0 %81 / 81100.0 %5 / 5
test_SortByDegree.c +
100.0%
+
100.0 %190 / 190100.0 %5 / 5
test_Vector_Structure.c +
100.0%
+
100.0 %85 / 85100.0 %5 / 5
test_Matrix_Structure.c +
100.0%
+
100.0 %78 / 78100.0 %5 / 5
test_Cached_Degree.c +
100.0%
+
100.0 %82 / 82100.0 %5 / 5
test_DisplayGraph.c +
100.0%
+
100.0 %132 / 132100.0 %6 / 6
test_minmax.c +
100.0%
+
100.0 %135 / 135100.0 %6 / 6
test_Sort.c +
100.0%
+
100.0 %142 / 142100.0 %6 / 6
test_IsEqual.c +
100.0%
+
100.0 %210 / 210100.0 %6 / 6
test_MMRead.c +
100.0%
+
100.0 %287 / 287100.0 %10 / 10
test_TriangleCount.c +
100.0%
+
100.0 %255 / 255100.0 %12 / 12
test_BreadthFirstSearch.c +
100.0%
+
100.0 %341 / 341100.0 %12 / 12
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/index-sort-l.html b/src/test/index-sort-l.html new file mode 100644 index 0000000000..642f892ed3 --- /dev/null +++ b/src/test/index-sort-l.html @@ -0,0 +1,543 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/testHitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:41094109100.0 %
Date:2024-08-29 20:08:04Functions:162162100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
LG_brutal_teardown.c +
100.0%
+
100.0 %4 / 4100.0 %1 / 1
test_acutest.c +
100.0%
+
100.0 %4 / 4100.0 %1 / 1
LG_brutal_setup.c +
100.0%
+
100.0 %8 / 8100.0 %1 / 1
LG_check_vector.c +
100.0%
+
100.0 %9 / 9100.0 %1 / 1
test_Init_errors.c +
100.0%
+
100.0 %11 / 11100.0 %1 / 1
test_WallClockTime.c +
100.0%
+
100.0 %12 / 12100.0 %1 / 1
test_Multiply_size_t.c +
100.0%
+
100.0 %12 / 12100.0 %1 / 1
test_fopen.c +
100.0%
+
100.0 %13 / 13100.0 %2 / 2
test_KindName.c +
100.0%
+
100.0 %24 / 24100.0 %4 / 4
test_Init.c +
100.0%
+
100.0 %25 / 25100.0 %1 / 1
test_NumThreads.c +
100.0%
+
100.0 %28 / 28100.0 %1 / 1
LG_brutal_malloc.c +
100.0%
+
100.0 %29 / 29100.0 %4 / 4
LG_check_tri.c +
100.0%
+
100.0 %35 / 35100.0 %1 / 1
test_vector.c +
100.0%
+
100.0 %39 / 39100.0 %2 / 2
test_Cached_NDiag.c +
100.0%
+
100.0 %45 / 45100.0 %4 / 4
test_Malloc.c +
100.0%
+
100.0 %46 / 46100.0 %1 / 1
LG_check_export.c +
100.0%
+
100.0 %59 / 59100.0 %1 / 1
LG_check_cc.c +
100.0%
+
100.0 %63 / 63100.0 %1 / 1
test_New.c +
100.0%
+
100.0 %67 / 67100.0 %5 / 5
LG_check_bfs.c +
100.0%
+
100.0 %71 / 71100.0 %1 / 1
test_Betweenness.c +
100.0%
+
100.0 %72 / 72100.0 %3 / 3
test_Xinit.c +
100.0%
+
100.0 %76 / 76100.0 %2 / 2
test_Cached_AT.c +
100.0%
+
100.0 %76 / 76100.0 %4 / 4
LG_heap.h +
100.0%
+
100.0 %78 / 78100.0 %5 / 5
test_Matrix_Structure.c +
100.0%
+
100.0 %78 / 78100.0 %5 / 5
test_Cached_SymmetricStructure.c +
100.0%
+
100.0 %79 / 79100.0 %4 / 4
test_export.c +
100.0%
+
100.0 %80 / 80100.0 %2 / 2
test_SampleDegree.c +
100.0%
+
100.0 %81 / 81100.0 %5 / 5
test_DeleteCached.c +
100.0%
+
100.0 %82 / 82100.0 %4 / 4
test_Cached_Degree.c +
100.0%
+
100.0 %82 / 82100.0 %5 / 5
test_Vector_Structure.c +
100.0%
+
100.0 %85 / 85100.0 %5 / 5
test_Type.c +
100.0%
+
100.0 %94 / 94100.0 %2 / 2
test_PageRank.c +
100.0%
+
100.0 %97 / 97100.0 %2 / 2
test_ConnectedComponents.c +
100.0%
+
100.0 %115 / 115100.0 %4 / 4
test_DisplayGraph.c +
100.0%
+
100.0 %132 / 132100.0 %6 / 6
LG_check_sssp.c +
100.0%
+
100.0 %135 / 135100.0 %1 / 1
test_minmax.c +
100.0%
+
100.0 %135 / 135100.0 %6 / 6
test_CheckGraph.c +
100.0%
+
100.0 %136 / 136100.0 %5 / 5
test_Vector_Print.c +
100.0%
+
100.0 %142 / 142100.0 %2 / 2
test_Sort.c +
100.0%
+
100.0 %142 / 142100.0 %6 / 6
test_SortByDegree.c +
100.0%
+
100.0 %190 / 190100.0 %5 / 5
test_IsEqual.c +
100.0%
+
100.0 %210 / 210100.0 %6 / 6
test_SingleSourceShortestPath.c +
100.0%
+
100.0 %225 / 225100.0 %4 / 4
test_TriangleCount.c +
100.0%
+
100.0 %255 / 255100.0 %12 / 12
test_MMRead.c +
100.0%
+
100.0 %287 / 287100.0 %10 / 10
test_BreadthFirstSearch.c +
100.0%
+
100.0 %341 / 341100.0 %12 / 12
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/index.html b/src/test/index.html new file mode 100644 index 0000000000..1c4e2f2337 --- /dev/null +++ b/src/test/index.html @@ -0,0 +1,543 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/testHitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:41094109100.0 %
Date:2024-08-29 20:08:04Functions:162162100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
LG_brutal_malloc.c +
100.0%
+
100.0 %29 / 29100.0 %4 / 4
LG_brutal_setup.c +
100.0%
+
100.0 %8 / 8100.0 %1 / 1
LG_brutal_teardown.c +
100.0%
+
100.0 %4 / 4100.0 %1 / 1
LG_check_bfs.c +
100.0%
+
100.0 %71 / 71100.0 %1 / 1
LG_check_cc.c +
100.0%
+
100.0 %63 / 63100.0 %1 / 1
LG_check_export.c +
100.0%
+
100.0 %59 / 59100.0 %1 / 1
LG_check_sssp.c +
100.0%
+
100.0 %135 / 135100.0 %1 / 1
LG_check_tri.c +
100.0%
+
100.0 %35 / 35100.0 %1 / 1
LG_check_vector.c +
100.0%
+
100.0 %9 / 9100.0 %1 / 1
LG_heap.h +
100.0%
+
100.0 %78 / 78100.0 %5 / 5
test_Betweenness.c +
100.0%
+
100.0 %72 / 72100.0 %3 / 3
test_BreadthFirstSearch.c +
100.0%
+
100.0 %341 / 341100.0 %12 / 12
test_Cached_AT.c +
100.0%
+
100.0 %76 / 76100.0 %4 / 4
test_Cached_Degree.c +
100.0%
+
100.0 %82 / 82100.0 %5 / 5
test_Cached_NDiag.c +
100.0%
+
100.0 %45 / 45100.0 %4 / 4
test_Cached_SymmetricStructure.c +
100.0%
+
100.0 %79 / 79100.0 %4 / 4
test_CheckGraph.c +
100.0%
+
100.0 %136 / 136100.0 %5 / 5
test_ConnectedComponents.c +
100.0%
+
100.0 %115 / 115100.0 %4 / 4
test_DeleteCached.c +
100.0%
+
100.0 %82 / 82100.0 %4 / 4
test_DisplayGraph.c +
100.0%
+
100.0 %132 / 132100.0 %6 / 6
test_Init.c +
100.0%
+
100.0 %25 / 25100.0 %1 / 1
test_Init_errors.c +
100.0%
+
100.0 %11 / 11100.0 %1 / 1
test_IsEqual.c +
100.0%
+
100.0 %210 / 210100.0 %6 / 6
test_KindName.c +
100.0%
+
100.0 %24 / 24100.0 %4 / 4
test_MMRead.c +
100.0%
+
100.0 %287 / 287100.0 %10 / 10
test_Malloc.c +
100.0%
+
100.0 %46 / 46100.0 %1 / 1
test_Matrix_Structure.c +
100.0%
+
100.0 %78 / 78100.0 %5 / 5
test_Multiply_size_t.c +
100.0%
+
100.0 %12 / 12100.0 %1 / 1
test_New.c +
100.0%
+
100.0 %67 / 67100.0 %5 / 5
test_NumThreads.c +
100.0%
+
100.0 %28 / 28100.0 %1 / 1
test_PageRank.c +
100.0%
+
100.0 %97 / 97100.0 %2 / 2
test_SampleDegree.c +
100.0%
+
100.0 %81 / 81100.0 %5 / 5
test_SingleSourceShortestPath.c +
100.0%
+
100.0 %225 / 225100.0 %4 / 4
test_Sort.c +
100.0%
+
100.0 %142 / 142100.0 %6 / 6
test_SortByDegree.c +
100.0%
+
100.0 %190 / 190100.0 %5 / 5
test_TriangleCount.c +
100.0%
+
100.0 %255 / 255100.0 %12 / 12
test_Type.c +
100.0%
+
100.0 %94 / 94100.0 %2 / 2
test_Vector_Print.c +
100.0%
+
100.0 %142 / 142100.0 %2 / 2
test_Vector_Structure.c +
100.0%
+
100.0 %85 / 85100.0 %5 / 5
test_WallClockTime.c +
100.0%
+
100.0 %12 / 12100.0 %1 / 1
test_Xinit.c +
100.0%
+
100.0 %76 / 76100.0 %2 / 2
test_acutest.c +
100.0%
+
100.0 %4 / 4100.0 %1 / 1
test_export.c +
100.0%
+
100.0 %80 / 80100.0 %2 / 2
test_fopen.c +
100.0%
+
100.0 %13 / 13100.0 %2 / 2
test_minmax.c +
100.0%
+
100.0 %135 / 135100.0 %6 / 6
test_vector.c +
100.0%
+
100.0 %39 / 39100.0 %2 / 2
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_Betweenness.c.func-sort-c.html b/src/test/test_Betweenness.c.func-sort-c.html new file mode 100644 index 0000000000..600b940fa9 --- /dev/null +++ b/src/test/test_Betweenness.c.func-sort-c.html @@ -0,0 +1,84 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_Betweenness.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_Betweenness.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:7272100.0 %
Date:2024-08-29 20:08:04Functions:33100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_bc1
test_bc_brutal1
difference3
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_Betweenness.c.func.html b/src/test/test_Betweenness.c.func.html new file mode 100644 index 0000000000..4374035255 --- /dev/null +++ b/src/test/test_Betweenness.c.func.html @@ -0,0 +1,84 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_Betweenness.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_Betweenness.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:7272100.0 %
Date:2024-08-29 20:08:04Functions:33100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
difference3
test_bc1
test_bc_brutal1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_Betweenness.c.gcov.html b/src/test/test_Betweenness.c.gcov.html new file mode 100644 index 0000000000..0388c3ba48 --- /dev/null +++ b/src/test/test_Betweenness.c.gcov.html @@ -0,0 +1,401 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_Betweenness.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_Betweenness.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:7272100.0 %
Date:2024-08-29 20:08:04Functions:33100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph/src/test/test_Betweenness.c: test cases for BC (GAP method)
+       3             : // -----------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include <stdio.h>
+      19             : #include <acutest.h>
+      20             : 
+      21             : #include <LAGraph_test.h>
+      22             : 
+      23             : #define LEN 512
+      24             : char msg [LAGRAPH_MSG_LEN] ;
+      25             : char filename [LEN+1] ;
+      26             : LAGraph_Graph G = NULL ;
+      27             : 
+      28             : //------------------------------------------------------------------------------
+      29             : // difference: compare the LAGraph and GAP results
+      30             : //------------------------------------------------------------------------------
+      31             : 
+      32             : float difference (GrB_Vector bc, double *gap_result) ;
+      33             : 
+      34           3 : float difference (GrB_Vector bc, double *gap_result)
+      35             : {
+      36           3 :     GrB_Vector diff = NULL, gap_bc = NULL ;
+      37           3 :     GrB_Index n = 0 ;
+      38           3 :     OK (GrB_Vector_size (&n, bc)) ;
+      39           3 :     OK (GrB_Vector_new (&gap_bc, GrB_FP32, n)) ;
+      40         138 :     for (int i = 0 ; i < n ; i++)
+      41             :     {
+      42         135 :         OK (GrB_Vector_setElement_FP64 (gap_bc, gap_result [i], i)) ;
+      43             :     }
+      44             :     // diff = max (abs (gap_bc - bc))
+      45           3 :     OK (GrB_Vector_new (&diff, GrB_FP32, n)) ;
+      46           3 :     OK (GrB_eWiseAdd (diff, NULL, NULL, GrB_MINUS_FP32, gap_bc, bc,
+      47             :         NULL)) ;
+      48           3 :     OK (GrB_apply (diff, NULL, NULL, GrB_ABS_FP32, diff, NULL)) ;
+      49           3 :     float err = 0 ;
+      50           3 :     OK (GrB_reduce (&err, NULL, GrB_MAX_MONOID_FP32, diff, NULL)) ;
+      51           3 :     OK (GrB_free (&diff)) ;
+      52           3 :     OK (GrB_free (&gap_bc)) ;
+      53           3 :     return (err) ;
+      54             : }
+      55             : 
+      56             : //------------------------------------------------------------------------------
+      57             : // results for karate graph
+      58             : //------------------------------------------------------------------------------
+      59             : 
+      60             : // Results obtained from GAP/bc.cc, but with each source node reduce by n-1
+      61             : // where n is the # of nodes in the graph, and prior to normalization.
+      62             : // (The GAP benchmark results are incorrect for the 4 source nodes, since the
+      63             : // score includes n-1 paths of length zero, which LAGraph excludes).
+      64             : 
+      65             : //  Read Time:           0.00770
+      66             : //  Build Time:          0.00021
+      67             : //  Graph has 34 nodes and 156 directed edges for degree: 4
+      68             : //  Read Time:           0.00163
+      69             : //  Graph has 34 nodes and 156 directed edges for degree: 4
+      70             : //      a                0.00001
+      71             : //  source: 6
+      72             : //      b                0.00143
+      73             : //      p                0.00118
+      74             : //  source: 29
+      75             : //      b                0.00012
+      76             : //      p                0.00010
+      77             : //  source: 0
+      78             : //      b                0.00009
+      79             : //      p                0.00007
+      80             : //  source: 9
+      81             : //      b                0.00010
+      82             : //      p                0.00008
+      83             : 
+      84             : GrB_Index karate_sources [4] = { 6, 29, 0, 9 } ;
+      85             : 
+      86             : double karate_bc [34] = {
+      87             :     43.7778,
+      88             :     2.83333,
+      89             :     26.9143,
+      90             :     0.722222,
+      91             :     0.333333,
+      92             :     1.83333,
+      93             :     1.5,
+      94             :     0,
+      95             :     9.09524,
+      96             :     0,
+      97             :     0,
+      98             :     0,
+      99             :     0,
+     100             :     5.19206,
+     101             :     0,
+     102             :     0,
+     103             :     0,
+     104             :     0,
+     105             :     0,
+     106             :     4.58095,
+     107             :     0,
+     108             :     0,
+     109             :     0,
+     110             :     2.4,
+     111             :     0,
+     112             :     0.422222,
+     113             :     0,
+     114             :     1.28889,
+     115             :     0,
+     116             :     0,
+     117             :     0.733333,
+     118             :     14.5508,
+     119             :     17.1873,
+     120             :     40.6349 } ;
+     121             : 
+     122             : // Trial Time:          0.00369
+     123             : // Average Time:        0.00369
+     124             : 
+     125             : //------------------------------------------------------------------------------
+     126             : // results for west0067 graph
+     127             : //------------------------------------------------------------------------------
+     128             : 
+     129             : // Read Time:           0.00213
+     130             : // Build Time:          0.00019
+     131             : // Graph has 67 nodes and 292 directed edges for degree: 4
+     132             : // Read Time:           0.00158
+     133             : // Graph has 67 nodes and 292 directed edges for degree: 4
+     134             :     // a                0.00001
+     135             : // source: 13
+     136             :     // b                0.00285
+     137             :     // p                0.00013
+     138             : // source: 58
+     139             :     // b                0.00028
+     140             :     // p                0.00515
+     141             : // source: 1
+     142             :     // b                0.00015
+     143             :     // p                0.00012
+     144             : // source: 18
+     145             :     // b                0.00012
+     146             :     // p                0.00009
+     147             : 
+     148             : GrB_Index west0067_sources [4] = { 13, 58, 1, 18 } ;
+     149             : 
+     150             : double west0067_bc [67] = {
+     151             :     7.37262,
+     152             :     5.3892,
+     153             :     4.53788,
+     154             :     3.25952,
+     155             :     11.9139,
+     156             :     5.73571,
+     157             :     5.65336,
+     158             :     1.5,
+     159             :     19.2719,
+     160             :     0.343137,
+     161             :     0.0833333,
+     162             :     0.666667,
+     163             :     1.80882,
+     164             :     12.4246,
+     165             :     1.92647,
+     166             :     22.0458,
+     167             :     4.7381,
+     168             :     34.8611,
+     169             :     0.1,
+     170             :     29.8358,
+     171             :     9.52807,
+     172             :     9.71836,
+     173             :     17.3334,
+     174             :     54.654,
+     175             :     23.3118,
+     176             :     7.31765,
+     177             :     2.52381,
+     178             :     6.96905,
+     179             :     19.2291,
+     180             :     6.97003,
+     181             :     33.0464,
+     182             :     7.20128,
+     183             :     3.78571,
+     184             :     7.87698,
+     185             :     15.3556,
+     186             :     7.43333,
+     187             :     7.19091,
+     188             :     9.20411,
+     189             :     1.10325,
+     190             :     6.38095,
+     191             :     17.808,
+     192             :     5.18172,
+     193             :     25.8441,
+     194             :     7.91581,
+     195             :     1.13501,
+     196             :     0,
+     197             :     2.53004,
+     198             :     2.48168,
+     199             :     8.84857,
+     200             :     3.80708,
+     201             :     1.16978,
+     202             :     0.0714286,
+     203             :     1.76786,
+     204             :     3.06661,
+     205             :     12.0742,
+     206             :     1.6,
+     207             :     4.73908,
+     208             :     2.3701,
+     209             :     3.75,
+     210             :     1.08571,
+     211             :     1.69697,
+     212             :     0,
+     213             :     0.571429,
+     214             :     0,
+     215             :     0,
+     216             :     2.22381,
+     217             :     0.659341 } ;
+     218             : 
+     219             : //  Trial Time:          0.00912
+     220             : //  Average Time:        0.00912
+     221             : 
+     222             : //------------------------------------------------------------------------------
+     223             : // test_bc
+     224             : //------------------------------------------------------------------------------
+     225             : 
+     226           1 : void test_bc (void)
+     227             : {
+     228           1 :     LAGraph_Init (msg) ;
+     229           1 :     GrB_Matrix A = NULL ;
+     230           1 :     GrB_Vector centrality = NULL ;
+     231           1 :     int niters = 0 ;
+     232             : 
+     233             :     // create the karate graph
+     234           1 :     snprintf (filename, LEN, LG_DATA_DIR "%s", "karate.mtx") ;
+     235           1 :     FILE *f = fopen (filename, "r") ;
+     236           1 :     TEST_CHECK (f != NULL) ;
+     237           1 :     OK (LAGraph_MMRead (&A, f, msg)) ;
+     238           1 :     OK (fclose (f)) ;
+     239           1 :     OK (LAGraph_New (&G, &A, LAGraph_ADJACENCY_UNDIRECTED, msg)) ;
+     240           1 :     TEST_CHECK (A == NULL) ;    // A has been moved into G->A
+     241             : 
+     242             :     // compute its betweenness centrality
+     243           1 :     OK (LAGr_Betweenness (&centrality, G, karate_sources, 4, msg)) ;
+     244           1 :     printf ("\nkarate bc:\n") ;
+     245           1 :     OK (LAGraph_Delete (&G, msg)) ;
+     246             : 
+     247             :     // compare with GAP:
+     248           1 :     float err = difference (centrality, karate_bc) ;
+     249           1 :     printf ("karate:   err: %e\n", err) ;
+     250           1 :     TEST_CHECK (err < 1e-4) ;
+     251           1 :     OK (GrB_free (&centrality)) ;
+     252             : 
+     253             :     // create the west0067 graph
+     254           1 :     snprintf (filename, LEN, LG_DATA_DIR "%s", "west0067.mtx") ;
+     255           1 :     f = fopen (filename, "r") ;
+     256           1 :     TEST_CHECK (f != NULL) ;
+     257           1 :     OK (LAGraph_MMRead (&A, f, msg)) ;
+     258           1 :     OK (fclose (f)) ;
+     259           1 :     OK (LAGraph_New (&G, &A, LAGraph_ADJACENCY_DIRECTED, msg)) ;
+     260           1 :     TEST_CHECK (A == NULL) ;    // A has been moved into G->A
+     261           1 :     OK (LAGraph_Cached_AT (G, msg)) ;
+     262             : 
+     263             :     // compute its betweenness centrality
+     264           1 :     OK (LAGr_Betweenness (&centrality, G, west0067_sources, 4, msg)) ;
+     265           1 :     printf ("\nwest0067 bc:\n") ;
+     266           1 :     OK (LAGraph_Delete (&G, msg)) ;
+     267             : 
+     268             :     // compare with GAP:
+     269           1 :     err = difference (centrality, west0067_bc) ;
+     270           1 :     printf ("west0067: err: %e\n", err) ;
+     271           1 :     TEST_CHECK (err < 1e-4) ;
+     272           1 :     OK (GrB_free (&centrality)) ;
+     273             : 
+     274           1 :     LAGraph_Finalize (msg) ;
+     275           1 : }
+     276             : 
+     277             : //------------------------------------------------------------------------------
+     278             : // test_bc_brutal: test BetweenessCentraliy with brutal malloc debugging
+     279             : //------------------------------------------------------------------------------
+     280             : 
+     281             : #if LAGRAPH_SUITESPARSE
+     282           1 : void test_bc_brutal (void)
+     283             : {
+     284           1 :     OK (LG_brutal_setup (msg)) ;
+     285             : 
+     286           1 :     GrB_Matrix A = NULL ;
+     287           1 :     GrB_Vector centrality = NULL ;
+     288           1 :     int niters = 0 ;
+     289             : 
+     290             :     // create the karate graph
+     291           1 :     snprintf (filename, LEN, LG_DATA_DIR "%s", "karate.mtx") ;
+     292           1 :     FILE *f = fopen (filename, "r") ;
+     293           1 :     TEST_CHECK (f != NULL) ;
+     294           1 :     OK (LAGraph_MMRead (&A, f, msg)) ;
+     295           1 :     OK (fclose (f)) ;
+     296           1 :     OK (LAGraph_New (&G, &A, LAGraph_ADJACENCY_UNDIRECTED, msg)) ;
+     297           1 :     TEST_CHECK (A == NULL) ;    // A has been moved into G->A
+     298           1 :     printf ("\n") ;
+     299             : 
+     300             :     // compute its betweenness centrality
+     301         141 :     LG_BRUTAL_BURBLE (LAGr_Betweenness (&centrality, G,
+     302             :             karate_sources, 4, msg)) ;
+     303             : 
+     304             :     // compare with GAP:
+     305           1 :     float err = difference (centrality, karate_bc) ;
+     306           1 :     printf ("karate:   err: %e\n", err) ;
+     307           1 :     TEST_CHECK (err < 1e-4) ;
+     308           1 :     OK (GrB_free (&centrality)) ;
+     309           1 :     OK (LAGraph_Delete (&G, msg)) ;
+     310             : 
+     311           1 :     OK (LG_brutal_teardown (msg)) ;
+     312           1 : }
+     313             : #endif
+     314             : 
+     315             : //------------------------------------------------------------------------------
+     316             : // list of tests
+     317             : //------------------------------------------------------------------------------
+     318             : 
+     319             : TEST_LIST = {
+     320             :     {"test_bc", test_bc},
+     321             :     #if LAGRAPH_SUITESPARSE
+     322             :     {"test_bc_brutal", test_bc_brutal },
+     323             :     #endif
+     324             :     {NULL, NULL}
+     325             : };
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_BreadthFirstSearch.c.func-sort-c.html b/src/test/test_BreadthFirstSearch.c.func-sort-c.html new file mode 100644 index 0000000000..4d8baf1fca --- /dev/null +++ b/src/test/test_BreadthFirstSearch.c.func-sort-c.html @@ -0,0 +1,120 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_BreadthFirstSearch.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_BreadthFirstSearch.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:341341100.0 %
Date:2024-08-29 20:08:04Functions:1212100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_BreadthFirstSearch_both1
test_BreadthFirstSearch_invalid_graph1
test_BreadthFirstSearch_invalid_src1
test_BreadthFirstSearch_level1
test_BreadthFirstSearch_many1
test_BreadthFirstSearch_neither1
test_BreadthFirstSearch_parent1
test_bfs_brutal1
check_karate_levels305
setup6
teardown6
check_karate_parents307
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_BreadthFirstSearch.c.func.html b/src/test/test_BreadthFirstSearch.c.func.html new file mode 100644 index 0000000000..2ce3ffac9b --- /dev/null +++ b/src/test/test_BreadthFirstSearch.c.func.html @@ -0,0 +1,120 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_BreadthFirstSearch.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_BreadthFirstSearch.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:341341100.0 %
Date:2024-08-29 20:08:04Functions:1212100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
check_karate_levels305
check_karate_parents307
setup6
teardown6
test_BreadthFirstSearch_both1
test_BreadthFirstSearch_invalid_graph1
test_BreadthFirstSearch_invalid_src1
test_BreadthFirstSearch_level1
test_BreadthFirstSearch_many1
test_BreadthFirstSearch_neither1
test_BreadthFirstSearch_parent1
test_bfs_brutal1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_BreadthFirstSearch.c.gcov.html b/src/test/test_BreadthFirstSearch.c.gcov.html new file mode 100644 index 0000000000..76db392d94 --- /dev/null +++ b/src/test/test_BreadthFirstSearch.c.gcov.html @@ -0,0 +1,753 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_BreadthFirstSearch.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_BreadthFirstSearch.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:341341100.0 %
Date:2024-08-29 20:08:04Functions:1212100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //----------------------------------------------------------------------------
+       2             : // LAGraph/src/test/test_BreadthFirstSearch.c: test cases for triangle
+       3             : // counting algorithms
+       4             : // ----------------------------------------------------------------------------
+       5             : 
+       6             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       7             : // SPDX-License-Identifier: BSD-2-Clause
+       8             : //
+       9             : // For additional details (including references to third party source code and
+      10             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      11             : // Contributors.txt for a full list of contributors. Created, in part, with
+      12             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      13             : // DM22-0790
+      14             : 
+      15             : // Contributed by Scott McMillan, SEI/CMU, and Timothy A. Davis, Texas A&M
+      16             : // University
+      17             : 
+      18             : //-----------------------------------------------------------------------------
+      19             : 
+      20             : #include <stdio.h>
+      21             : #include <acutest.h>
+      22             : 
+      23             : #include <LAGraph_test.h>
+      24             : #include <graph_zachary_karate.h>
+      25             : #include "LG_alg_internal.h"
+      26             : 
+      27             : char msg[LAGRAPH_MSG_LEN];
+      28             : LAGraph_Graph G = NULL;
+      29             : 
+      30             : //-----------------------------------------------------------------------------
+      31             : // Valid results for Karate graph:
+      32             : //-----------------------------------------------------------------------------
+      33             : 
+      34             : GrB_Index const SRC = 30;
+      35             : // the levels of the tree for the Karate graph, assuming source node 30:
+      36             : GrB_Index const LEVELS30[] = {2, 1, 2, 2, 3, 3, 3, 2, 1, 2, 3, 3,
+      37             :                               3, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2,
+      38             :                               3, 3, 2, 2, 2, 2, 0, 2, 1, 1};
+      39             : // Karate BFS parents, with source node 30.  This assumes the parent is the min
+      40             : // of the valid set of parents:
+      41             : // GrB_Index const PARENT30[] = { 1, 30,  1,  1,  0,  0,  0,  1, 30, 33,  0,  0,
+      42             : //                                0,  1, 32, 32,  5,  1, 32,  1, 32,  1, 32, 32,
+      43             : //                               27, 23, 33, 33, 33, 32, 30, 32, 30, 30};
+      44             : #define xx (-1)
+      45             : // The following are valid parents for each node, with source node of 30:
+      46             : GrB_Index const PARENT30 [34][3] = {
+      47             :     {  1,  8, xx },     // node 0 can have parents 1 or 8
+      48             :     { 30, xx, xx },     // node 1, parent 30
+      49             :     {  1,  8, 32 },     // node 2, parents 1, 8, or 32, etc
+      50             :     {  1, xx, xx },     // node 3
+      51             :     {  0, xx, xx },     // node 4
+      52             :     {  0, xx, xx },     // node 5
+      53             :     {  0, xx, xx },     // node 6
+      54             :     {  1, xx, xx },     // node 7
+      55             :     { 30, xx, xx },     // node 8
+      56             :     { 33, xx, xx },     // node 9
+      57             :     {  0, xx, xx },     // node 10
+      58             :     {  0, xx, xx },     // node 11
+      59             :     {  0,  3, xx },     // node 12
+      60             :     {  1, 33, xx },     // node 13
+      61             :     { 32, 33, xx },     // node 14
+      62             :     { 32, 33, xx },     // node 15
+      63             :     {  5,  6, xx },     // node 16
+      64             :     {  1, xx, xx },     // node 17
+      65             :     { 32, 33, xx },     // node 18
+      66             :     {  1, 33, xx },     // node 19
+      67             :     { 32, 33, xx },     // node 20
+      68             :     {  1, xx, xx },     // node 21
+      69             :     { 32, 33, xx },     // node 22
+      70             :     { 32, 33, xx },     // node 23
+      71             :     { 27, 31, xx },     // node 24
+      72             :     { 23, 31, xx },     // node 25
+      73             :     { 33, xx, xx },     // node 26
+      74             :     { 33, xx, xx },     // node 27
+      75             :     { 33, xx, xx },     // node 28
+      76             :     { 32, 33, xx },     // node 29
+      77             :     { 30, xx, xx },     // node 30, source node
+      78             :     { 32, 33, xx },     // node 31
+      79             :     { 30, xx, xx },     // node 32
+      80             :     { 30, xx, xx }} ;   // node 33
+      81             : #undef xx
+      82             : 
+      83             : //-----------------------------------------------------------------------------
+      84             : 
+      85             : #define LEN 512
+      86             : char filename [LEN+1] ;
+      87             : 
+      88             : typedef struct
+      89             : {
+      90             :     LAGraph_Kind kind ;
+      91             :     const char *name ;
+      92             : }
+      93             : matrix_info ;
+      94             : 
+      95             : const matrix_info files [ ] =
+      96             : {
+      97             :     { LAGraph_ADJACENCY_UNDIRECTED, "A.mtx" },
+      98             :     { LAGraph_ADJACENCY_DIRECTED,   "cover.mtx" },
+      99             :     { LAGraph_ADJACENCY_UNDIRECTED, "jagmesh7.mtx" },
+     100             :     { LAGraph_ADJACENCY_DIRECTED,   "ldbc-cdlp-directed-example.mtx" },
+     101             :     { LAGraph_ADJACENCY_UNDIRECTED, "ldbc-cdlp-undirected-example.mtx" },
+     102             :     { LAGraph_ADJACENCY_DIRECTED,   "ldbc-directed-example.mtx" },
+     103             :     { LAGraph_ADJACENCY_UNDIRECTED, "ldbc-undirected-example.mtx" },
+     104             :     { LAGraph_ADJACENCY_UNDIRECTED, "ldbc-wcc-example.mtx" },
+     105             :     { LAGraph_ADJACENCY_UNDIRECTED, "LFAT5.mtx" },
+     106             :     { LAGraph_ADJACENCY_DIRECTED,   "msf1.mtx" },
+     107             :     { LAGraph_ADJACENCY_DIRECTED,   "msf2.mtx" },
+     108             :     { LAGraph_ADJACENCY_DIRECTED,   "msf3.mtx" },
+     109             :     { LAGraph_ADJACENCY_DIRECTED,   "sample2.mtx" },
+     110             :     { LAGraph_ADJACENCY_DIRECTED,   "sample.mtx" },
+     111             :     { LAGraph_ADJACENCY_DIRECTED,   "olm1000.mtx" },
+     112             :     { LAGraph_ADJACENCY_UNDIRECTED, "bcsstk13.mtx" },
+     113             :     { LAGraph_ADJACENCY_DIRECTED,   "cryg2500.mtx" },
+     114             :     { LAGraph_ADJACENCY_UNDIRECTED, "tree-example.mtx" },
+     115             :     { LAGraph_ADJACENCY_DIRECTED,   "west0067.mtx" },
+     116             :     { LAGraph_ADJACENCY_UNDIRECTED, "karate.mtx" },
+     117             :     { LAGraph_ADJACENCY_DIRECTED,   "matrix_bool.mtx" },
+     118             :     { LAGraph_ADJACENCY_DIRECTED,   "skew_fp32.mtx" },
+     119             :     { LAGraph_ADJACENCY_UNDIRECTED, "pushpull.mtx" },
+     120             :     { LAGRAPH_UNKNOWN, "" },
+     121             : } ;
+     122             : 
+     123             : //****************************************************************************
+     124           7 : bool check_karate_parents30(GrB_Vector parents)
+     125             : {
+     126             :     // An update to SS:GrB can result in different, yet valid, parent vectors
+     127             :     // (even single-threaded).  The LG_check_bfs works fine and those tests
+     128             :     // pass.  This parent test looks for any valid parent vector.
+     129             : 
+     130           7 :     GrB_Index n = 0;
+     131           7 :     TEST_CHECK(0 == GrB_Vector_size(&n, parents));
+     132           7 :     TEST_CHECK(ZACHARY_NUM_NODES == n);
+     133           7 :     TEST_CHECK(0 == GrB_Vector_nvals(&n, parents));
+     134           7 :     TEST_CHECK(ZACHARY_NUM_NODES == n);
+     135             : 
+     136           7 :     bool ok = false ;
+     137             :     int64_t parent_id;
+     138         211 :     for (GrB_Index ix = 0; ix < ZACHARY_NUM_NODES; ++ix)
+     139             :     {
+     140         205 :         TEST_CHECK(0 == GrB_Vector_extractElement(&parent_id, parents, ix));
+     141             :         // prior test:
+     142             : //      TEST_CHECK(parent_id == PARENT30[ix][0]);
+     143             : //      TEST_MSG("Parent check failed for node %ld: ans,comp = %ld,%ld\n",
+     144             : //          ix, PARENT30[ix][0], parent_id);
+     145             :         // more general test:
+     146         205 :         ok = false ;
+     147         207 :         for (int k = 0 ; k <= 2 ; k++)
+     148             :         {
+     149         207 :             int valid_parent_id = PARENT30 [ix][k] ;
+     150         207 :             if (valid_parent_id < 0)
+     151             :             {
+     152             :                 // end of the list of valid parent ids
+     153           1 :                 ok = false ;
+     154           1 :                 break ;
+     155             :             }
+     156         206 :             if (parent_id == valid_parent_id)
+     157             :             {
+     158             :                 // a match is found
+     159         204 :                 ok = true ;
+     160         204 :                 break ;
+     161             :             }
+     162             :         }
+     163         205 :         if (!ok) break ;
+     164             :     }
+     165             : 
+     166           7 :     return ok;
+     167             : }
+     168             : 
+     169             : //****************************************************************************
+     170           5 : bool check_karate_levels30(GrB_Vector levels)
+     171             : {
+     172           5 :     GrB_Index n = 0;
+     173           5 :     TEST_CHECK(0 == GrB_Vector_size(&n, levels) );
+     174           5 :     TEST_CHECK(ZACHARY_NUM_NODES == n);
+     175           5 :     TEST_CHECK(0 == GrB_Vector_nvals(&n, levels) );
+     176           5 :     TEST_CHECK(ZACHARY_NUM_NODES == n);
+     177             : 
+     178             :     int64_t lvl;
+     179         175 :     for (GrB_Index ix = 0; ix < ZACHARY_NUM_NODES; ++ix)
+     180             :     {
+     181         170 :         TEST_CHECK(0 == GrB_Vector_extractElement(&lvl, levels, ix) );
+     182         170 :         TEST_CHECK(lvl == LEVELS30[ix] );
+     183         170 :         TEST_MSG("Level check failed for node %g: ans,comp = %g,%g\n",
+     184             :                  (double) ix, (double) LEVELS30[ix], (double) lvl);
+     185             :     }
+     186             : 
+     187           5 :     return true;
+     188             : }
+     189             : 
+     190             : //****************************************************************************
+     191           6 : void setup(void)
+     192             : {
+     193           6 :     LAGraph_Init(msg);
+     194             :     int retval;
+     195           6 :     GrB_Matrix A = NULL;
+     196             : 
+     197           6 :     TEST_CHECK(0 == GrB_Matrix_new(&A, GrB_UINT32,
+     198             :                                    ZACHARY_NUM_NODES, ZACHARY_NUM_NODES) );
+     199           6 :     TEST_CHECK(0 == GrB_Matrix_build(A, ZACHARY_I, ZACHARY_J, ZACHARY_V,
+     200             :                                      ZACHARY_NUM_EDGES, GrB_LOR) );
+     201             : 
+     202           6 :     retval = LAGraph_New(&G, &A, LAGraph_ADJACENCY_UNDIRECTED, msg);
+     203           6 :     TEST_CHECK(retval == 0);
+     204           6 :     TEST_MSG("retval = %d (%s)", retval, msg);
+     205           6 : }
+     206             : 
+     207             : //****************************************************************************
+     208           6 : void teardown(void)
+     209             : {
+     210           6 :     int retval = LAGraph_Delete(&G, msg);
+     211           6 :     TEST_CHECK(retval == 0);
+     212           6 :     TEST_MSG("retval = %d (%s)", retval, msg);
+     213             : 
+     214           6 :     G = NULL;
+     215           6 :     LAGraph_Finalize(msg);
+     216           6 : }
+     217             : 
+     218             : //****************************************************************************
+     219           1 : void test_BreadthFirstSearch_invalid_graph(void)
+     220             : {
+     221           1 :     setup();
+     222             :     int retval;
+     223           1 :     LAGraph_Graph graph = NULL;
+     224             : 
+     225           1 :     retval = LAGr_BreadthFirstSearch(NULL, NULL, graph, 0, msg);
+     226           1 :     TEST_CHECK(retval == GrB_NULL_POINTER);
+     227           1 :     TEST_MSG("retval = %d (%s)", retval, msg);
+     228             : 
+     229           1 :     retval = LG_BreadthFirstSearch_vanilla(NULL, NULL, graph, 0, msg);
+     230           1 :     TEST_CHECK(retval == GrB_NULL_POINTER);
+     231           1 :     TEST_MSG("retval = %d (%s)", retval, msg);
+     232             : 
+     233           1 :     teardown();
+     234           1 : }
+     235             : 
+     236             : //****************************************************************************
+     237           1 : void test_BreadthFirstSearch_invalid_src(void)
+     238             : {
+     239           1 :     setup();
+     240             :     int retval;
+     241             :     GrB_Index n;
+     242           1 :     TEST_CHECK(0 == GrB_Matrix_nrows(&n, (G->A)));
+     243             : 
+     244           1 :     GrB_Vector parent = NULL ;
+     245           1 :     GrB_Vector level  = NULL ;
+     246             : 
+     247           1 :     retval = LAGr_BreadthFirstSearch(&level, NULL, G, n, msg);
+     248           1 :     TEST_CHECK(retval == GrB_INVALID_INDEX);
+     249           1 :     TEST_MSG("retval = %d (%s)", retval, msg);
+     250             : 
+     251           1 :     retval = LG_BreadthFirstSearch_vanilla(&level, NULL, G, n, msg);
+     252           1 :     TEST_CHECK(retval == GrB_INVALID_INDEX);
+     253           1 :     TEST_MSG("retval = %d (%s)", retval, msg);
+     254             : 
+     255           1 :     retval = LAGr_BreadthFirstSearch(NULL, &parent, G, n, msg);
+     256           1 :     TEST_CHECK(retval == GrB_INVALID_INDEX);
+     257           1 :     TEST_MSG("retval = %d (%s)", retval, msg);
+     258             : 
+     259           1 :     retval = LG_BreadthFirstSearch_vanilla(NULL, &parent, G, n, msg);
+     260           1 :     TEST_CHECK(retval == GrB_INVALID_INDEX);
+     261           1 :     TEST_MSG("retval = %d (%s)", retval, msg);
+     262             : 
+     263           1 :     teardown();
+     264           1 : }
+     265             : 
+     266             : //****************************************************************************
+     267           1 : void test_BreadthFirstSearch_neither(void)
+     268             : {
+     269           1 :     setup();
+     270             :     int retval;
+     271             : 
+     272           1 :     printf ("\nTest level and parent both NULL:\n") ;
+     273             : 
+     274           1 :     LAGraph_PrintLevel pr = LAGraph_COMPLETE_VERBOSE ;
+     275           1 :     retval = LAGraph_Graph_Print (G, pr, stdout, msg) ;
+     276           1 :     TEST_CHECK(retval == GrB_SUCCESS);
+     277             : 
+     278           1 :     retval = LAGr_BreadthFirstSearch(NULL, NULL, G, 0, msg);
+     279           1 :     TEST_CHECK(retval == GrB_NULL_POINTER);
+     280           1 :     TEST_MSG("retval = %d (%s)", retval, msg);
+     281             : 
+     282           1 :     retval = LG_BreadthFirstSearch_vanilla(NULL, NULL, G, 0, msg);
+     283           1 :     TEST_CHECK(retval == GrB_NULL_POINTER);
+     284           1 :     TEST_MSG("retval = %d (%s)", retval, msg);
+     285             : 
+     286           1 :     retval = LAGr_BreadthFirstSearch(NULL, NULL, G, 0, msg);
+     287           1 :     TEST_CHECK(retval == GrB_NULL_POINTER);
+     288           1 :     TEST_MSG("retval = %d (%s)", retval, msg);
+     289             : 
+     290           1 :     retval = LG_BreadthFirstSearch_vanilla(NULL, NULL, G, 0, msg);
+     291           1 :     TEST_CHECK(retval == GrB_NULL_POINTER);
+     292           1 :     TEST_MSG("retval = %d (%s)", retval, msg);
+     293             : 
+     294           1 :     teardown();
+     295           1 : }
+     296             : 
+     297             : //****************************************************************************
+     298           1 : void test_BreadthFirstSearch_parent(void)
+     299             : {
+     300           1 :     setup();
+     301             :     int retval;
+     302             : 
+     303           1 :     GrB_Vector parent    = NULL;
+     304           1 :     GrB_Vector parent_do = NULL;
+     305             : 
+     306           1 :     OK (LAGraph_Cached_OutDegree (G, msg)) ;
+     307             : 
+     308           1 :     retval = LAGr_BreadthFirstSearch(NULL, &parent, G, 30, msg);
+     309           1 :     TEST_CHECK(retval == 0);
+     310           1 :     TEST_MSG("retval = %d (%s)", retval, msg);
+     311           1 :     TEST_CHECK(check_karate_parents30(parent));
+     312           1 :     retval = LG_check_bfs (NULL, parent, G, 30, msg) ;
+     313           1 :     TEST_CHECK (retval == 0) ;
+     314             : 
+     315             :     // mangle the parent vector, just to check check_karate_parents30
+     316           1 :     OK (GrB_Vector_setElement (parent, 0, 0)) ;
+     317           1 :     TEST_CHECK(!check_karate_parents30(parent));
+     318           1 :     TEST_CHECK(0 == GrB_free(&parent));
+     319             : 
+     320           1 :     retval = LG_BreadthFirstSearch_vanilla(NULL, &parent, G, 30, msg);
+     321           1 :     TEST_CHECK(retval == 0);
+     322           1 :     TEST_MSG("retval = %d (%s)", retval, msg);
+     323           1 :     TEST_CHECK(check_karate_parents30(parent));
+     324           1 :     retval = LG_check_bfs (NULL, parent, G, 30, msg) ;
+     325           1 :     TEST_CHECK (retval == 0) ;
+     326           1 :     TEST_CHECK(0 == GrB_free(&parent));
+     327             : 
+     328           1 :     retval = LAGr_BreadthFirstSearch(NULL, &parent_do, G, 30, msg);
+     329           1 :     TEST_CHECK(retval == 0);
+     330           1 :     TEST_MSG("retval = %d (%s)", retval, msg);
+     331           1 :     TEST_CHECK(check_karate_parents30(parent_do));
+     332           1 :     retval = LG_check_bfs (NULL, parent_do, G, 30, msg) ;
+     333           1 :     TEST_CHECK (retval == 0) ;
+     334           1 :     TEST_CHECK(0 == GrB_free(&parent_do));
+     335             : 
+     336           1 :     retval = LG_BreadthFirstSearch_vanilla(NULL, &parent_do, G, 30, msg);
+     337           1 :     TEST_CHECK(retval == 0);
+     338           1 :     TEST_MSG("retval = %d (%s)", retval, msg);
+     339           1 :     TEST_CHECK(check_karate_parents30(parent_do));
+     340           1 :     retval = LG_check_bfs (NULL, parent_do, G, 30, msg) ;
+     341           1 :     TEST_CHECK (retval == 0) ;
+     342           1 :     TEST_CHECK(0 == GrB_free(&parent_do));
+     343             : 
+     344           1 :     GrB_Index n = 0 ;
+     345           1 :     TEST_CHECK (0 == GrB_Matrix_nrows (&n, G->A)) ;
+     346          35 :     for (GrB_Index src = 0 ; src < n ; src++)
+     347             :     {
+     348          34 :         retval = LAGr_BreadthFirstSearch(NULL, &parent, G, src, msg);
+     349          34 :         TEST_CHECK(retval == 0);
+     350          34 :         retval = LG_check_bfs (NULL, parent, G, src, msg) ;
+     351          34 :         TEST_CHECK (retval == 0) ;
+     352          34 :         TEST_CHECK(0 == GrB_free(&parent));
+     353             : 
+     354          34 :         retval = LG_BreadthFirstSearch_vanilla(NULL, &parent, G, src, msg);
+     355          34 :         TEST_CHECK(retval == 0);
+     356          34 :         retval = LG_check_bfs (NULL, parent, G, src, msg) ;
+     357          34 :         TEST_CHECK (retval == 0) ;
+     358          34 :         TEST_CHECK(0 == GrB_free(&parent));
+     359             :     }
+     360             : 
+     361           1 :     teardown();
+     362           1 : }
+     363             : 
+     364             : //****************************************************************************
+     365           1 : void test_BreadthFirstSearch_level(void)
+     366             : {
+     367           1 :     setup();
+     368             :     int retval;
+     369             : 
+     370           1 :     GrB_Vector level    = NULL;
+     371           1 :     GrB_Vector level_do = NULL;
+     372           1 :     OK (LAGraph_Cached_OutDegree (G, msg)) ;
+     373             : 
+     374           1 :     retval = LAGr_BreadthFirstSearch(&level, NULL, G, 30, msg);
+     375           1 :     TEST_CHECK(retval == 0);
+     376           1 :     TEST_MSG("retval = %d (%s)", retval, msg);
+     377           1 :     TEST_CHECK(check_karate_levels30(level));
+     378           1 :     retval = LG_check_bfs (level, NULL, G, 30, msg) ;
+     379           1 :     TEST_CHECK (retval == 0) ;
+     380           1 :     TEST_CHECK(0 == GrB_free(&level));
+     381             : 
+     382           1 :     retval = LG_BreadthFirstSearch_vanilla(&level, NULL, G, 30, msg);
+     383           1 :     TEST_CHECK(retval == 0);
+     384           1 :     TEST_MSG("retval = %d (%s)", retval, msg);
+     385           1 :     TEST_CHECK(check_karate_levels30(level));
+     386           1 :     retval = LG_check_bfs (level, NULL, G, 30, msg) ;
+     387           1 :     TEST_CHECK (retval == 0) ;
+     388           1 :     TEST_CHECK(0 == GrB_free(&level));
+     389             : 
+     390           1 :     retval = LAGr_BreadthFirstSearch(&level_do, NULL, G, 30, msg);
+     391           1 :     TEST_CHECK(retval == 0);
+     392           1 :     TEST_MSG("retval = %d (%s)", retval, msg);
+     393           1 :     TEST_CHECK(check_karate_levels30(level_do));
+     394           1 :     retval = LG_check_bfs (level_do, NULL, G, 30, msg) ;
+     395           1 :     TEST_CHECK (retval == 0) ;
+     396           1 :     TEST_CHECK(0 == GrB_free(&level_do));
+     397             : 
+     398           1 :     GrB_Index n = 0 ;
+     399           1 :     TEST_CHECK (0 == GrB_Matrix_nrows (&n, G->A)) ;
+     400          35 :     for (GrB_Index src = 0 ; src < n ; src++)
+     401             :     {
+     402             : 
+     403          34 :         retval = LAGr_BreadthFirstSearch(&level, NULL, G, src, msg);
+     404          34 :         TEST_CHECK(retval == 0);
+     405          34 :         retval = LG_check_bfs (level, NULL, G, src, msg) ;
+     406          34 :         TEST_CHECK (retval == 0) ;
+     407          34 :         TEST_CHECK(0 == GrB_free(&level));
+     408             : 
+     409          34 :         retval = LG_BreadthFirstSearch_vanilla(&level, NULL, G, src, msg);
+     410          34 :         TEST_CHECK(retval == 0);
+     411          34 :         retval = LG_check_bfs (level, NULL, G, src, msg) ;
+     412          34 :         TEST_CHECK (retval == 0) ;
+     413          34 :         TEST_CHECK(0 == GrB_free(&level));
+     414             : 
+     415             :     }
+     416             : 
+     417           1 :     teardown();
+     418           1 : }
+     419             : 
+     420             : //****************************************************************************
+     421           1 : void test_BreadthFirstSearch_both(void)
+     422             : {
+     423           1 :     setup();
+     424             :     int retval;
+     425             : 
+     426           1 :     OK (LAGraph_Cached_OutDegree (G, msg)) ;
+     427           1 :     GrB_Vector parent    = NULL;
+     428           1 :     GrB_Vector level    = NULL;
+     429           1 :     retval = LAGr_BreadthFirstSearch(&level, &parent, G, 30, msg);
+     430           1 :     TEST_CHECK(retval == 0);
+     431           1 :     TEST_MSG("retval = %d (%s)", retval, msg);
+     432           1 :     TEST_CHECK(check_karate_levels30(level));
+     433           1 :     TEST_CHECK(check_karate_parents30(parent));
+     434             : 
+     435           1 :     retval = LG_check_bfs (level, parent, G, 30, msg) ;
+     436           1 :     TEST_CHECK (retval == 0) ;
+     437             : 
+     438           1 :     TEST_CHECK(0 == GrB_free(&parent));
+     439           1 :     TEST_CHECK(0 == GrB_free(&level));
+     440             : 
+     441           1 :     GrB_Vector parent_do = NULL;
+     442           1 :     GrB_Vector level_do = NULL;
+     443           1 :     retval = LAGr_BreadthFirstSearch(&level_do, &parent_do, G, 30, msg);
+     444           1 :     TEST_CHECK(retval == 0);
+     445           1 :     TEST_MSG("retval = %d (%s)", retval, msg);
+     446           1 :     TEST_CHECK(check_karate_levels30(level_do));
+     447           1 :     TEST_CHECK(check_karate_parents30(parent_do));
+     448           1 :     retval = LG_check_bfs (level_do, parent_do, G, 30, msg) ;
+     449           1 :     TEST_CHECK (retval == 0) ;
+     450           1 :     TEST_CHECK(0 == GrB_free(&parent_do));
+     451           1 :     TEST_CHECK(0 == GrB_free(&level_do));
+     452             : 
+     453           1 :     GrB_Index n = 0 ;
+     454           1 :     TEST_CHECK (0 == GrB_Matrix_nrows (&n, G->A)) ;
+     455             : 
+     456          35 :     for (GrB_Index src = 0 ; src < n ; src++)
+     457             :     {
+     458          34 :         retval = LAGr_BreadthFirstSearch(&level, &parent, G, src, msg);
+     459          34 :         TEST_CHECK(retval == 0);
+     460          34 :         retval = LG_check_bfs (level, parent, G, src, msg) ;
+     461          34 :         TEST_CHECK (retval == 0) ;
+     462          34 :         TEST_CHECK(0 == GrB_free(&parent));
+     463          34 :         TEST_CHECK(0 == GrB_free(&level));
+     464             :     }
+     465             : 
+     466           1 :     teardown();
+     467           1 : }
+     468             : 
+     469             : //****************************************************************************
+     470           1 : void test_BreadthFirstSearch_many(void)
+     471             : {
+     472           1 :     LAGraph_Init(msg);
+     473           1 :     GrB_Matrix A = NULL ;
+     474             : 
+     475           1 :     for (int k = 0 ; ; k++)
+     476          23 :     {
+     477             : 
+     478             :         // load the adjacency matrix as A
+     479          24 :         const char *aname = files [k].name ;
+     480          24 :         LAGraph_Kind kind = files [k].kind ;
+     481          24 :         if (strlen (aname) == 0) break;
+     482          23 :         TEST_CASE (aname) ;
+     483          23 :         printf ("\nMatrix: %s\n", aname) ;
+     484          23 :         snprintf (filename, LEN, LG_DATA_DIR "%s", aname) ;
+     485          23 :         FILE *f = fopen (filename, "r") ;
+     486          23 :         TEST_CHECK (f != NULL) ;
+     487          23 :         OK (LAGraph_MMRead (&A, f, msg)) ;
+     488          23 :         OK (fclose (f)) ;
+     489          23 :         TEST_MSG ("Loading of adjacency matrix failed") ;
+     490             : 
+     491             :         // create the graph
+     492          23 :         OK (LAGraph_New (&G, &A, kind, msg)) ;
+     493          23 :         TEST_CHECK (A == NULL) ;    // A has been moved into G->A
+     494             : 
+     495          23 :         GrB_Index n = 0 ;
+     496          23 :         OK (GrB_Matrix_nrows (&n, G->A)) ;
+     497             : 
+     498          69 :         for (int caching = 0 ; caching <= 1 ; caching++)
+     499             :         {
+     500             :             // run the BFS
+     501          46 :             int64_t step = (n > 100) ? (3*n/4) : ((n/4) + 1) ;
+     502         190 :             for (int64_t src = 0 ; src < n ; src += step)
+     503             :             {
+     504         144 :                 GrB_Vector parent = NULL ;
+     505         144 :                 GrB_Vector level = NULL ;
+     506             : 
+     507             :                 int64_t maxlevel ;
+     508             :                 GrB_Index nvisited ;
+     509             : 
+     510         144 :                 OK (LAGr_BreadthFirstSearch (&level, &parent, G, src, msg)) ;
+     511         144 :                 OK (LG_check_bfs (level, parent, G, src, msg)) ;
+     512         144 :                 OK (GrB_reduce (&maxlevel, NULL, GrB_MAX_MONOID_INT64,
+     513             :                     level, NULL)) ;
+     514         144 :                 OK (GrB_Vector_nvals (&nvisited, level)) ;
+     515             :                 {
+     516         144 :                     printf ("src %g n: %g max level: %g nvisited: %g\n",
+     517             :                         (double) src, (double) n, (double) maxlevel,
+     518             :                         (double) nvisited) ;
+     519             :                 }
+     520         144 :                 OK (GrB_free(&parent));
+     521         144 :                 OK (GrB_free(&level));
+     522             : 
+     523         144 :                 OK (LG_BreadthFirstSearch_vanilla (&level, &parent,
+     524             :                     G, src, msg)) ;
+     525         144 :                 OK (LG_check_bfs (level, parent, G, src, msg)) ;
+     526         144 :                 OK (GrB_reduce (&maxlevel, NULL, GrB_MAX_MONOID_INT64,
+     527             :                     level, NULL)) ;
+     528         144 :                 OK (GrB_Vector_nvals (&nvisited, level)) ;
+     529             :                 {
+     530         144 :                     printf ("src %g n: %g max level: %g nvisited: %g\n",
+     531             :                         (double) src, (double) n, (double) maxlevel,
+     532             :                         (double) nvisited) ;
+     533             :                 }
+     534         144 :                 OK (GrB_free(&parent));
+     535         144 :                 OK (GrB_free(&level));
+     536             : 
+     537         144 :                 OK (LAGr_BreadthFirstSearch (NULL, &parent, G, src, msg)) ;
+     538         144 :                 OK (LG_check_bfs (NULL, parent, G, src, msg)) ;
+     539         144 :                 OK (GrB_free(&parent));
+     540             : 
+     541         144 :                 OK (LG_BreadthFirstSearch_vanilla (NULL, &parent,
+     542             :                     G, src, msg)) ;
+     543         144 :                 OK (LG_check_bfs (NULL, parent, G, src, msg)) ;
+     544         144 :                 OK (GrB_free(&parent));
+     545             : 
+     546         144 :                 OK (LAGr_BreadthFirstSearch (&level, NULL, G, src, msg)) ;
+     547         144 :                 OK (LG_check_bfs (level, NULL, G, src, msg)) ;
+     548         144 :                 OK (GrB_free(&level));
+     549             : 
+     550         144 :                 OK (LG_BreadthFirstSearch_vanilla (&level, NULL, G, src, msg)) ;
+     551         144 :                 OK (LG_check_bfs (level, NULL, G, src, msg)) ;
+     552         144 :                 OK (GrB_free(&level));
+     553             : 
+     554             :             }
+     555             : 
+     556             :             // create its cached properties
+     557          46 :             int ok_result = (kind == LAGraph_ADJACENCY_UNDIRECTED) ?
+     558          46 :                 LAGRAPH_CACHE_NOT_NEEDED : GrB_SUCCESS ;
+     559          46 :             int result = LAGraph_Cached_AT (G, msg) ;
+     560          46 :             TEST_CHECK (result == ok_result) ;
+     561          46 :             OK (LAGraph_CheckGraph (G, msg)) ;
+     562          46 :             OK (LAGraph_Cached_OutDegree (G, msg)) ;
+     563          46 :             OK (LAGraph_CheckGraph (G, msg)) ;
+     564          46 :             result = LAGraph_Cached_InDegree (G, msg) ;
+     565          46 :             TEST_CHECK (result == ok_result) ;
+     566          46 :             OK (LAGraph_CheckGraph (G, msg)) ;
+     567             :         }
+     568             : 
+     569          23 :         OK (LAGraph_Delete (&G, msg)) ;
+     570             :     }
+     571             : 
+     572           1 :     LAGraph_Finalize(msg);
+     573           1 : }
+     574             : 
+     575             : //------------------------------------------------------------------------------
+     576             : // test_bfs_brutal
+     577             : //------------------------------------------------------------------------------
+     578             : 
+     579             : #if LAGRAPH_SUITESPARSE
+     580           1 : void test_bfs_brutal (void)
+     581             : {
+     582           1 :     OK (LG_brutal_setup (msg)) ;
+     583           1 :     GrB_Matrix A = NULL ;
+     584             : 
+     585           1 :     for (int k = 0 ; ; k++)
+     586          23 :     {
+     587             :         // load the adjacency matrix as A
+     588          24 :         const char *aname = files [k].name ;
+     589          24 :         LAGraph_Kind kind = files [k].kind ;
+     590          24 :         if (strlen (aname) == 0) break;
+     591          23 :         TEST_CASE (aname) ;
+     592          23 :         printf ("\nMatrix: %s\n", aname) ;
+     593          23 :         snprintf (filename, LEN, LG_DATA_DIR "%s", aname) ;
+     594          23 :         FILE *f = fopen (filename, "r") ;
+     595          23 :         TEST_CHECK (f != NULL) ;
+     596          23 :         OK (LAGraph_MMRead (&A, f, msg)) ;
+     597          23 :         OK (fclose (f)) ;
+     598          23 :         TEST_MSG ("Loading of adjacency matrix failed") ;
+     599             :         // create the graph
+     600          23 :         OK (LAGraph_New (&G, &A, kind, msg)) ;
+     601          23 :         TEST_CHECK (A == NULL) ;    // A has been moved into G->A
+     602          23 :         GrB_Index n = 0 ;
+     603          23 :         OK (GrB_Matrix_nrows (&n, G->A)) ;
+     604          23 :         if (n >= 1000)
+     605             :         {
+     606             :             // only do the small graphs
+     607           5 :             printf ("skipped\n") ;
+     608           5 :             OK (LAGraph_Delete (&G, msg)) ;
+     609           5 :             continue ;
+     610             :         }
+     611             : 
+     612          54 :         for (int caching = 0 ; caching <= 1 ; caching++)
+     613             :         {
+     614             :             // run the BFS
+     615          36 :             int64_t step = (n > 100) ? (3*n/4) : ((n/4) + 1) ;
+     616         160 :             for (int64_t src = 0 ; src < n ; src += step)
+     617             :             {
+     618         124 :                 GrB_Vector parent = NULL ;
+     619         124 :                 GrB_Vector level = NULL ;
+     620             : 
+     621             :                 // parent and level with SS:GrB
+     622        4921 :                 LG_BRUTAL_BURBLE (LAGr_BreadthFirstSearch (&level, &parent, G, src, msg)) ;
+     623         124 :                 OK (LG_check_bfs (level, parent, G, src, msg)) ;
+     624         124 :                 OK (GrB_free (&parent)) ;
+     625         124 :                 OK (GrB_free (&level)) ;
+     626             : 
+     627             :                 // level only with SS:GrB
+     628        3996 :                 LG_BRUTAL (LAGr_BreadthFirstSearch (&level, NULL, G, src, msg)) ;
+     629         124 :                 OK (LG_check_bfs (level, NULL, G, src, msg)) ;
+     630         124 :                 OK (GrB_free (&level)) ;
+     631             : 
+     632             :                 // parent and level with vanilla
+     633        5014 :                 LG_BRUTAL (LG_BreadthFirstSearch_vanilla (&level,
+     634             :                     &parent, G, src, msg)) ;
+     635         124 :                 OK (LG_check_bfs (level, parent, G, src, msg)) ;
+     636         124 :                 OK (GrB_free (&parent)) ;
+     637         124 :                 OK (GrB_free (&level)) ;
+     638             : 
+     639             :                 // level-only with vanilla
+     640        3942 :                 LG_BRUTAL (LG_BreadthFirstSearch_vanilla (&level, NULL,
+     641             :                         G, src, msg)) ;
+     642         124 :                 OK (LG_check_bfs (level, NULL, G, src, msg)) ;
+     643         124 :                 OK (GrB_free (&level)) ;
+     644             :             }
+     645             : 
+     646             :             // create its cached properties
+     647          36 :             int ok_result = (kind == LAGraph_ADJACENCY_UNDIRECTED) ?
+     648          36 :                 LAGRAPH_CACHE_NOT_NEEDED : GrB_SUCCESS ;
+     649          36 :             int result = LAGraph_Cached_AT (G, msg) ;
+     650          36 :             TEST_CHECK (result == ok_result) ;
+     651          36 :             OK (LAGraph_Cached_OutDegree (G, msg)) ;
+     652          36 :             result = LAGraph_Cached_InDegree (G, msg) ;
+     653          36 :             TEST_CHECK (result == ok_result) ;
+     654             :         }
+     655             : 
+     656          18 :         OK (LAGraph_Delete (&G, msg)) ;
+     657             :     }
+     658             : 
+     659           1 :     OK (LG_brutal_teardown (msg)) ;
+     660           1 : }
+     661             : #endif
+     662             : 
+     663             : //****************************************************************************
+     664             : //****************************************************************************
+     665             : TEST_LIST = {
+     666             :     {"BreadthFirstSearch_invalid_graph", test_BreadthFirstSearch_invalid_graph},
+     667             :     {"BreadthFirstSearch_invalid_src", test_BreadthFirstSearch_invalid_src},
+     668             :     {"BreadthFirstSearch_neither", test_BreadthFirstSearch_neither},
+     669             :     {"BreadthFirstSearch_parent", test_BreadthFirstSearch_parent},
+     670             :     {"BreadthFirstSearch_level", test_BreadthFirstSearch_level},
+     671             :     {"BreadthFirstSearch_both", test_BreadthFirstSearch_both},
+     672             :     {"BreadthFirstSearch_many", test_BreadthFirstSearch_many},
+     673             :     #if LAGRAPH_SUITESPARSE
+     674             :     {"BreadthFirstSearch_brutal", test_bfs_brutal },
+     675             :     #endif
+     676             :     {NULL, NULL}
+     677             : } ;
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_Cached_AT.c.func-sort-c.html b/src/test/test_Cached_AT.c.func-sort-c.html new file mode 100644 index 0000000000..96f5b459a0 --- /dev/null +++ b/src/test/test_Cached_AT.c.func-sort-c.html @@ -0,0 +1,88 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_Cached_AT.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_Cached_AT.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:7676100.0 %
Date:2024-08-29 20:08:04Functions:44100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
setup1
teardown1
test_Cached_AT1
test_Cached_AT_brutal1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_Cached_AT.c.func.html b/src/test/test_Cached_AT.c.func.html new file mode 100644 index 0000000000..c654764f45 --- /dev/null +++ b/src/test/test_Cached_AT.c.func.html @@ -0,0 +1,88 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_Cached_AT.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_Cached_AT.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:7676100.0 %
Date:2024-08-29 20:08:04Functions:44100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
setup1
teardown1
test_Cached_AT1
test_Cached_AT_brutal1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_Cached_AT.c.gcov.html b/src/test/test_Cached_AT.c.gcov.html new file mode 100644 index 0000000000..084229434d --- /dev/null +++ b/src/test/test_Cached_AT.c.gcov.html @@ -0,0 +1,290 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_Cached_AT.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_Cached_AT.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:7676100.0 %
Date:2024-08-29 20:08:04Functions:44100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph/src/test/test_Cached_AT.c:  test LAGraph_Cached_AT
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include "LAGraph_test.h"
+      19             : 
+      20             : //------------------------------------------------------------------------------
+      21             : // global variables
+      22             : //------------------------------------------------------------------------------
+      23             : 
+      24             : LAGraph_Graph G = NULL ;
+      25             : char msg [LAGRAPH_MSG_LEN] ;
+      26             : GrB_Matrix A = NULL, B = NULL ;
+      27             : GrB_Type atype = NULL ;
+      28             : #define LEN 512
+      29             : char filename [LEN+1] ;
+      30             : char atype_name [LAGRAPH_MAX_NAME_LEN] ;
+      31             : 
+      32             : //------------------------------------------------------------------------------
+      33             : // setup: start a test
+      34             : //------------------------------------------------------------------------------
+      35             : 
+      36           1 : void setup (void)
+      37             : {
+      38           1 :     OK (LAGraph_Init (msg)) ;
+      39           1 : }
+      40             : 
+      41             : //------------------------------------------------------------------------------
+      42             : // teardown: finalize a test
+      43             : //------------------------------------------------------------------------------
+      44             : 
+      45           1 : void teardown (void)
+      46             : {
+      47           1 :     OK (LAGraph_Finalize (msg)) ;
+      48           1 : }
+      49             : 
+      50             : //------------------------------------------------------------------------------
+      51             : // test_Cached_AT:  test LAGraph_Cached_AT
+      52             : //------------------------------------------------------------------------------
+      53             : 
+      54             : typedef struct
+      55             : {
+      56             :     LAGraph_Kind kind ;
+      57             :     const char *name ;
+      58             : }
+      59             : matrix_info ;
+      60             : 
+      61             : const matrix_info files [ ] =
+      62             : {
+      63             :     LAGraph_ADJACENCY_DIRECTED,   "cover.mtx",
+      64             :     LAGraph_ADJACENCY_DIRECTED,   "ldbc-directed-example.mtx",
+      65             :     LAGraph_ADJACENCY_UNDIRECTED, "ldbc-undirected-example.mtx",
+      66             :     LAGRAPH_UNKNOWN,              ""
+      67             : } ;
+      68             : 
+      69             : //-----------------------------------------------------------------------------
+      70             : // test_Cached_AT
+      71             : //-----------------------------------------------------------------------------
+      72             : 
+      73           1 : void test_Cached_AT (void)
+      74             : {
+      75           1 :     setup ( ) ;
+      76             : 
+      77           1 :     for (int k = 0 ; ; k++)
+      78           3 :     {
+      79             : 
+      80             :         // load the matrix as A
+      81           4 :         const char *aname = files [k].name ;
+      82           4 :         int kind = files [k].kind ;
+      83           4 :         if (strlen (aname) == 0) break;
+      84           3 :         TEST_CASE (aname) ;
+      85           3 :         snprintf (filename, LEN, LG_DATA_DIR "%s", aname) ;
+      86           3 :         FILE *f = fopen (filename, "r") ;
+      87           3 :         TEST_CHECK (f != NULL) ;
+      88           3 :         OK (LAGraph_MMRead (&A, f, msg)) ;
+      89           3 :         OK (fclose (f)) ;
+      90           3 :         TEST_MSG ("Loading of adjacency matrix failed") ;
+      91             : 
+      92             :         // construct the graph G with adjacency matrix A
+      93           3 :         OK (LAGraph_New (&G, &A, kind, msg)) ;
+      94           3 :         TEST_CHECK (A == NULL) ;
+      95             : 
+      96             :         // create the G->AT cached property
+      97           3 :         int ok_result = (kind == LAGraph_ADJACENCY_UNDIRECTED) ?
+      98           3 :             LAGRAPH_CACHE_NOT_NEEDED : GrB_SUCCESS ;
+      99           3 :         int result = LAGraph_Cached_AT (G, msg) ;
+     100           3 :         TEST_CHECK (result == ok_result) ;
+     101             : 
+     102             :         // try to create it again; this should safely do nothing
+     103           3 :         result = LAGraph_Cached_AT (G, msg) ;
+     104           3 :         TEST_CHECK (result == ok_result) ;
+     105             : 
+     106             :         // check the result
+     107           3 :         if (kind == LAGraph_ADJACENCY_UNDIRECTED)
+     108             :         {
+     109           1 :             TEST_CHECK (G->AT == NULL) ;
+     110             :         }
+     111             :         else
+     112             :         {
+     113             :             // ensure G->A and G->AT are transposed of each other;
+     114             :             // B = (G->AT)'
+     115             :             GrB_Index nrows, ncols ;
+     116           2 :             OK (GrB_Matrix_nrows (&nrows, G->A)) ;
+     117           2 :             OK (GrB_Matrix_nrows (&ncols, G->A)) ;
+     118           2 :             OK (LAGraph_Matrix_TypeName (atype_name, G->A, msg)) ;
+     119           2 :             OK (LAGraph_TypeFromName (&atype, atype_name, msg)) ;
+     120           2 :             OK (GrB_Matrix_new (&B, atype, nrows, ncols)) ;
+     121           2 :             OK (GrB_transpose (B, NULL, NULL, G->AT, NULL)) ;
+     122             : 
+     123             :             // ensure B and G->A are the same
+     124             :             bool ok ;
+     125           2 :             OK (LAGraph_Matrix_IsEqual (&ok, G->A, B, msg)) ;
+     126           2 :             TEST_CHECK (ok) ;
+     127           2 :             TEST_MSG ("Test for G->A and B equal failed") ;
+     128           2 :             OK (GrB_free (&B)) ;
+     129             :         }
+     130             : 
+     131           3 :         OK (LAGraph_Delete (&G, msg)) ;
+     132             :     }
+     133             : 
+     134           1 :     teardown ( ) ;
+     135           1 : }
+     136             : 
+     137             : //-----------------------------------------------------------------------------
+     138             : // test_Cached_AT_brutal
+     139             : //-----------------------------------------------------------------------------
+     140             : 
+     141             : #if LAGRAPH_SUITESPARSE
+     142           1 : void test_Cached_AT_brutal (void)
+     143             : {
+     144           1 :     OK (LG_brutal_setup (msg)) ;
+     145             : 
+     146           1 :     for (int k = 0 ; ; k++)
+     147           3 :     {
+     148             : 
+     149             :         // load the matrix as A
+     150           4 :         const char *aname = files [k].name ;
+     151           4 :         int kind = files [k].kind ;
+     152           4 :         if (strlen (aname) == 0) break;
+     153           3 :         TEST_CASE (aname) ;
+     154           3 :         snprintf (filename, LEN, LG_DATA_DIR "%s", aname) ;
+     155           3 :         FILE *f = fopen (filename, "r") ;
+     156           3 :         TEST_CHECK (f != NULL) ;
+     157           3 :         OK (LAGraph_MMRead (&A, f, msg)) ;
+     158           3 :         OK (fclose (f)) ;
+     159           3 :         TEST_MSG ("Loading of adjacency matrix failed") ;
+     160             : 
+     161             :         // construct the graph G with adjacency matrix A
+     162           3 :         OK (LAGraph_New (&G, &A, kind, msg)) ;
+     163           3 :         TEST_CHECK (A == NULL) ;
+     164             : 
+     165             :         // create the G->AT cached property
+     166          13 :         LG_BRUTAL (LAGraph_Cached_AT (G, msg)) ;
+     167             : 
+     168             :         // try to create it again; this should safely do nothing
+     169           3 :         LG_BRUTAL (LAGraph_Cached_AT (G, msg)) ;
+     170             : 
+     171             :         // check the result
+     172           3 :         if (kind == LAGraph_ADJACENCY_UNDIRECTED)
+     173             :         {
+     174           1 :             TEST_CHECK (G->AT == NULL) ;
+     175             :         }
+     176             :         else
+     177             :         {
+     178             :             // ensure G->A and G->AT are transposed of each other;
+     179             :             // B = (G->AT)'
+     180             :             GrB_Index nrows, ncols ;
+     181           2 :             OK (GrB_Matrix_nrows (&nrows, G->A)) ;
+     182           2 :             OK (GrB_Matrix_nrows (&ncols, G->A)) ;
+     183           2 :             OK (LAGraph_Matrix_TypeName (atype_name, G->A, msg)) ;
+     184           2 :             OK (LAGraph_TypeFromName (&atype, atype_name, msg)) ;
+     185           2 :             OK (GrB_Matrix_new (&B, atype, nrows, ncols)) ;
+     186           2 :             OK (GrB_transpose (B, NULL, NULL, G->AT, NULL)) ;
+     187             : 
+     188             :             // ensure B and G->A are the same
+     189             :             bool ok ;
+     190          12 :             LG_BRUTAL (LAGraph_Matrix_IsEqual (&ok, G->A, B, msg)) ;
+     191           2 :             TEST_CHECK (ok) ;
+     192           2 :             TEST_MSG ("Test for G->A and B equal failed") ;
+     193           2 :             OK (GrB_free (&B)) ;
+     194             :         }
+     195             : 
+     196           3 :         OK (LAGraph_Delete (&G, msg)) ;
+     197             :     }
+     198             : 
+     199           1 :     OK (LG_brutal_teardown (msg)) ;
+     200           1 : }
+     201             : #endif
+     202             : 
+     203             : //-----------------------------------------------------------------------------
+     204             : // TEST_LIST: the list of tasks for this entire test
+     205             : //-----------------------------------------------------------------------------
+     206             : 
+     207             : TEST_LIST =
+     208             : {
+     209             :     { "test_AT", test_Cached_AT },
+     210             :     #if LAGRAPH_SUITESPARSE
+     211             :     { "test_AT_brutal", test_Cached_AT_brutal },
+     212             :     #endif
+     213             :     { NULL, NULL }
+     214             : } ;
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_Cached_Degree.c.func-sort-c.html b/src/test/test_Cached_Degree.c.func-sort-c.html new file mode 100644 index 0000000000..db596e7521 --- /dev/null +++ b/src/test/test_Cached_Degree.c.func-sort-c.html @@ -0,0 +1,92 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_Cached_Degree.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_Cached_Degree.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:8282100.0 %
Date:2024-08-29 20:08:04Functions:55100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
setup1
teardown1
test_Cached_Degree1
test_Cached_Degree_brutal1
check_degree516
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_Cached_Degree.c.func.html b/src/test/test_Cached_Degree.c.func.html new file mode 100644 index 0000000000..cf3e77d14d --- /dev/null +++ b/src/test/test_Cached_Degree.c.func.html @@ -0,0 +1,92 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_Cached_Degree.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_Cached_Degree.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:8282100.0 %
Date:2024-08-29 20:08:04Functions:55100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
check_degree516
setup1
teardown1
test_Cached_Degree1
test_Cached_Degree_brutal1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_Cached_Degree.c.gcov.html b/src/test/test_Cached_Degree.c.gcov.html new file mode 100644 index 0000000000..fc67380255 --- /dev/null +++ b/src/test/test_Cached_Degree.c.gcov.html @@ -0,0 +1,445 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_Cached_Degree.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_Cached_Degree.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:8282100.0 %
Date:2024-08-29 20:08:04Functions:55100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph/src/test/test_Cached_Degree.c:  test LAGraph_Cached_*Degree
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include "LAGraph_test.h"
+      19             : 
+      20             : //------------------------------------------------------------------------------
+      21             : // global variables
+      22             : //------------------------------------------------------------------------------
+      23             : 
+      24             : LAGraph_Graph G = NULL ;
+      25             : char msg [LAGRAPH_MSG_LEN] ;
+      26             : GrB_Matrix A = NULL ;
+      27             : #define LEN 512
+      28             : char filename [LEN+1] ;
+      29             : 
+      30             : //------------------------------------------------------------------------------
+      31             : // setup: start a test
+      32             : //------------------------------------------------------------------------------
+      33             : 
+      34           1 : void setup (void)
+      35             : {
+      36           1 :     OK (LAGraph_Init (msg)) ;
+      37           1 : }
+      38             : 
+      39             : //------------------------------------------------------------------------------
+      40             : // teardown: finalize a test
+      41             : //------------------------------------------------------------------------------
+      42             : 
+      43           1 : void teardown (void)
+      44             : {
+      45           1 :     OK (LAGraph_Finalize (msg)) ;
+      46           1 : }
+      47             : 
+      48             : //------------------------------------------------------------------------------
+      49             : // check_degree: check a row or column degree vector
+      50             : //------------------------------------------------------------------------------
+      51             : 
+      52         516 : void check_degree
+      53             : (
+      54             :     GrB_Vector Degree,
+      55             :     GrB_Index n,
+      56             :     const int *degree
+      57             : )
+      58             : {
+      59             :     GrB_Index n2 ;
+      60         516 :     OK (GrB_Vector_size (&n2, Degree)) ;
+      61         516 :     TEST_CHECK (n == n2) ;
+      62        6048 :     for (int k = 0 ; k < n ; k++)
+      63             :     {
+      64             :         int64_t degk ;
+      65        5532 :         GrB_Info info = GrB_Vector_extractElement (&degk, Degree, k) ;
+      66        5532 :         TEST_CHECK (info == GrB_NO_VALUE || info == GrB_SUCCESS) ;
+      67        5532 :         if (info == GrB_NO_VALUE)
+      68             :         {
+      69         156 :             TEST_CHECK (degree [k] == 0) ;
+      70             :         }
+      71             :         else
+      72             :         {
+      73        5376 :             TEST_CHECK (degree [k] == degk) ;
+      74             :         }
+      75             :     }
+      76         516 : }
+      77             : 
+      78             : //------------------------------------------------------------------------------
+      79             : // test_Cached_Degree:  test LAGraph_Cached_*Degree
+      80             : //------------------------------------------------------------------------------
+      81             : 
+      82             : typedef struct
+      83             : {
+      84             :     const char *name ;
+      85             :     const int out_deg [67] ;
+      86             :     const int in_deg [67] ;
+      87             : }
+      88             : matrix_info ;
+      89             : 
+      90             : const matrix_info files [ ] =
+      91             : {
+      92             :     { "A.mtx",
+      93             :         { 3, 5, 5, 5, 3, 4, 5,  },
+      94             :         { 3, 5, 5, 5, 3, 4, 5,  }, },
+      95             :      { "LFAT5.mtx",
+      96             :         { 3, 2, 2, 4, 4, 3, 3, 5, 5, 2, 2, 4, 4, 3,  },
+      97             :         { 3, 2, 2, 4, 4, 3, 3, 5, 5, 2, 2, 4, 4, 3,  }, },
+      98             :      { "cover.mtx",
+      99             :         { 2, 2, 1, 2, 1, 1, 3,  },
+     100             :         { 1, 1, 3, 2, 2, 2, 1,  }, },
+     101             :      { "cover_structure.mtx",
+     102             :         { 2, 2, 1, 2, 1, 1, 3,  },
+     103             :         { 1, 1, 3, 2, 2, 2, 1,  }, },
+     104             :      { "full.mtx",
+     105             :         { 3, 3, 3,  },
+     106             :         { 3, 3, 3,  }, },
+     107             :      { "full_symmetric.mtx",
+     108             :         { 4, 4, 4, 4,  },
+     109             :         { 4, 4, 4, 4,  }, },
+     110             :      { "karate.mtx",
+     111             :         { 16, 9, 10, 6, 3, 4, 4, 4, 5, 2, 3, 1, 2, 5, 2, 2, 2, 2, 2, 3,
+     112             :           2, 2, 2, 5, 3, 3, 2, 4, 3, 4, 4, 6, 12, 17,  },
+     113             :         { 16, 9, 10, 6, 3, 4, 4, 4, 5, 2, 3, 1, 2, 5, 2, 2, 2, 2, 2, 3,
+     114             :           2, 2, 2, 5, 3, 3, 2, 4, 3, 4, 4, 6, 12, 17,  }, },
+     115             :      { "ldbc-cdlp-directed-example.mtx",
+     116             :         { 3, 2, 2, 2, 3, 2, 3, 1,  },
+     117             :         { 2, 2, 2, 1, 3, 4, 3, 1,  }, },
+     118             :      { "ldbc-cdlp-undirected-example.mtx",
+     119             :         { 3, 2, 2, 3, 4, 3, 3, 4,  },
+     120             :         { 3, 2, 2, 3, 4, 3, 3, 4,  }, },
+     121             :      { "ldbc-directed-example-bool.mtx",
+     122             :         { 2, 3, 4, 0, 3, 2, 1, 1, 1, 0,  },
+     123             :         { 2, 0, 3, 5, 3, 0, 0, 2, 0, 2,  }, },
+     124             :      { "ldbc-directed-example-unweighted.mtx",
+     125             :         { 2, 3, 4, 0, 3, 2, 1, 1, 1, 0,  },
+     126             :         { 2, 0, 3, 5, 3, 0, 0, 2, 0, 2,  }, },
+     127             :      { "ldbc-directed-example.mtx",
+     128             :         { 2, 3, 4, 0, 3, 2, 1, 1, 1, 0,  },
+     129             :         { 2, 0, 3, 5, 3, 0, 0, 2, 0, 2,  }, },
+     130             :      { "ldbc-undirected-example-bool.mtx",
+     131             :         { 2, 4, 2, 3, 5, 2, 3, 2, 1,  },
+     132             :         { 2, 4, 2, 3, 5, 2, 3, 2, 1,  }, },
+     133             :      { "ldbc-undirected-example-unweighted.mtx",
+     134             :         { 2, 4, 2, 3, 5, 2, 3, 2, 1,  },
+     135             :         { 2, 4, 2, 3, 5, 2, 3, 2, 1,  }, },
+     136             :      { "ldbc-undirected-example.mtx",
+     137             :         { 2, 4, 2, 3, 5, 2, 3, 2, 1,  },
+     138             :         { 2, 4, 2, 3, 5, 2, 3, 2, 1,  }, },
+     139             :      { "ldbc-wcc-example.mtx",
+     140             :         { 3, 3, 5, 5, 5, 2, 1, 3, 1, 2,  },
+     141             :         { 3, 3, 5, 5, 5, 2, 1, 3, 1, 2,  }, },
+     142             :      { "matrix_bool.mtx",
+     143             :         { 2, 2, 1, 2, 1, 1, 3,  },
+     144             :         { 1, 1, 3, 2, 2, 2, 1,  }, },
+     145             :      { "matrix_fp32.mtx",
+     146             :         { 2, 2, 1, 2, 1, 1, 3,  },
+     147             :         { 1, 1, 3, 2, 2, 2, 1,  }, },
+     148             :      { "matrix_fp32_structure.mtx",
+     149             :         { 2, 2, 1, 2, 1, 1, 3,  },
+     150             :         { 1, 1, 3, 2, 2, 2, 1,  }, },
+     151             :      { "matrix_fp64.mtx",
+     152             :         { 2, 2, 1, 2, 1, 1, 3,  },
+     153             :         { 1, 1, 3, 2, 2, 2, 1,  }, },
+     154             :      { "matrix_int16.mtx",
+     155             :         { 2, 2, 1, 2, 1, 1, 3,  },
+     156             :         { 1, 1, 3, 2, 2, 2, 1,  }, },
+     157             :      { "matrix_int32.mtx",
+     158             :         { 2, 2, 1, 2, 1, 1, 3,  },
+     159             :         { 1, 1, 3, 2, 2, 2, 1,  }, },
+     160             :      { "matrix_int64.mtx",
+     161             :         { 2, 2, 1, 2, 1, 1, 3,  },
+     162             :         { 1, 1, 3, 2, 2, 2, 1,  }, },
+     163             :      { "matrix_int8.mtx",
+     164             :         { 2, 2, 1, 2, 1, 1, 3,  },
+     165             :         { 1, 1, 3, 2, 2, 2, 1,  }, },
+     166             :      { "matrix_uint16.mtx",
+     167             :         { 2, 2, 1, 2, 1, 1, 3,  },
+     168             :         { 1, 1, 3, 2, 2, 2, 1,  }, },
+     169             :      { "matrix_uint32.mtx",
+     170             :         { 2, 2, 1, 2, 1, 1, 3,  },
+     171             :         { 1, 1, 3, 2, 2, 2, 1,  }, },
+     172             :      { "matrix_uint64.mtx",
+     173             :         { 2, 2, 1, 2, 1, 1, 3,  },
+     174             :         { 1, 1, 3, 2, 2, 2, 1,  }, },
+     175             :      { "matrix_uint8.mtx",
+     176             :         { 2, 2, 1, 2, 1, 1, 3,  },
+     177             :         { 1, 1, 3, 2, 2, 2, 1,  }, },
+     178             :      { "msf1.mtx",
+     179             :         { 2, 2, 1, 1, 1, 1,  },
+     180             :         { 1, 1, 2, 2, 0, 2,  }, },
+     181             :      { "msf2.mtx",
+     182             :         { 2, 3, 3, 2, 1, 1, 0, 0,  },
+     183             :         { 0, 1, 1, 1, 2, 2, 2, 3,  }, },
+     184             :      { "msf3.mtx",
+     185             :         { 2, 2, 2, 1, 0,  },
+     186             :         { 0, 1, 1, 2, 3,  }, },
+     187             :      { "structure.mtx",
+     188             :         { 2, 2, 1, 2, 1, 1, 3,  },
+     189             :         { 1, 1, 3, 2, 2, 2, 1,  }, },
+     190             :      { "sample.mtx",
+     191             :         { 3, 2, 1, 2, 2, 1, 1, 0,  },
+     192             :         { 0, 1, 3, 1, 3, 1, 1, 2,  }, },
+     193             :      { "sample2.mtx",
+     194             :         { 2, 3, 4, 3, 5, 5, 3, 3,  },
+     195             :         { 2, 3, 4, 3, 5, 5, 3, 3,  }, },
+     196             :      { "skew_fp32.mtx",
+     197             :         { 3, 3, 3, 4, 3, 4,  },
+     198             :         { 3, 3, 3, 4, 3, 4,  }, },
+     199             :      { "skew_fp64.mtx",
+     200             :         { 3, 3, 3, 4, 3, 4,  },
+     201             :         { 3, 3, 3, 4, 3, 4,  }, },
+     202             :      { "skew_int16.mtx",
+     203             :         { 3, 3, 3, 4, 3, 4,  },
+     204             :         { 3, 3, 3, 4, 3, 4,  }, },
+     205             :      { "skew_int32.mtx",
+     206             :         { 3, 3, 3, 4, 3, 4,  },
+     207             :         { 3, 3, 3, 4, 3, 4,  }, },
+     208             :      { "skew_int64.mtx",
+     209             :         { 3, 3, 3, 4, 3, 4,  },
+     210             :         { 3, 3, 3, 4, 3, 4,  }, },
+     211             :      { "skew_int8.mtx",
+     212             :         { 3, 3, 3, 4, 3, 4,  },
+     213             :         { 3, 3, 3, 4, 3, 4,  }, },
+     214             :      { "tree-example.mtx",
+     215             :         { 1, 1, 2, 3, 2, 1,  },
+     216             :         { 1, 1, 2, 3, 2, 1,  }, },
+     217             :      { "west0067.mtx",
+     218             :         { 3, 3, 3, 3, 5, 5, 5, 5, 5, 6, 3, 3, 3, 3, 4, 5, 5, 5, 5, 5,
+     219             :           3, 3, 3, 3, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 3, 3, 3, 3, 5,
+     220             :           5, 5, 5, 5, 6, 3, 3, 3, 3, 4, 4, 4, 4, 4, 6, 1, 5, 5, 5, 5,
+     221             :           5, 5, 5, 5, 5, 5, 5,  },
+     222             :         { 10, 4, 4, 4, 4, 3, 5, 3, 3, 3, 3, 2, 5, 5, 5, 5, 4, 5, 2, 10,
+     223             :           3, 3, 3, 3, 3, 4, 4, 4, 4, 3, 10, 3, 3, 3, 3, 3, 10, 5, 5, 5,
+     224             :           5, 4, 5, 4, 4, 4, 4, 3, 10, 3, 3, 3, 3, 3, 10, 5, 5, 5, 5, 4,
+     225             :           5, 4, 4, 4, 4, 3, 5,  }, },
+     226             :      { "west0067_jumbled.mtx",
+     227             :         { 3, 3, 3, 3, 5, 5, 5, 5, 5, 6, 3, 3, 3, 3, 4, 5, 5, 5, 5, 5,
+     228             :           3, 3, 3, 3, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 3, 3, 3, 3, 5,
+     229             :           5, 5, 5, 5, 6, 3, 3, 3, 3, 4, 4, 4, 4, 4, 6, 1, 5, 5, 5, 5,
+     230             :           5, 5, 5, 5, 5, 5, 5,  },
+     231             :         { 10, 4, 4, 4, 4, 3, 5, 3, 3, 3, 3, 2, 5, 5, 5, 5, 4, 5, 2, 10,
+     232             :           3, 3, 3, 3, 3, 4, 4, 4, 4, 3, 10, 3, 3, 3, 3, 3, 10, 5, 5, 5,
+     233             :           5, 4, 5, 4, 4, 4, 4, 3, 10, 3, 3, 3, 3, 3, 10, 5, 5, 5, 5, 4,
+     234             :           5, 4, 4, 4, 4, 3, 5,  }, },
+     235             :     { "", { 0 }, { 0 }}
+     236             : } ;
+     237             : 
+     238             : //-----------------------------------------------------------------------------
+     239             : // test_Cached_Degree
+     240             : //-----------------------------------------------------------------------------
+     241             : 
+     242           1 : void test_Cached_Degree (void)
+     243             : {
+     244           1 :     setup ( ) ;
+     245             : 
+     246           1 :     for (int k = 0 ; ; k++)
+     247          43 :     {
+     248             : 
+     249             :         // load the matrix as A
+     250          44 :         const char *aname = files [k].name ;
+     251          44 :         if (strlen (aname) == 0) break;
+     252          43 :         const int *out_deg = files [k].out_deg ;
+     253          43 :         const int *in_deg = files [k].in_deg ;
+     254          43 :         TEST_CASE (aname) ;
+     255          43 :         snprintf (filename, LEN, LG_DATA_DIR "%s", aname) ;
+     256          43 :         FILE *f = fopen (filename, "r") ;
+     257          43 :         TEST_CHECK (f != NULL) ;
+     258          43 :         OK (LAGraph_MMRead (&A, f, msg)) ;
+     259          43 :         OK (fclose (f)) ;
+     260          43 :         TEST_MSG ("Loading of adjacency matrix failed") ;
+     261             : 
+     262             :         // construct the graph G with adjacency matrix A
+     263          43 :         OK (LAGraph_New (&G, &A, LAGraph_ADJACENCY_DIRECTED, msg)) ;
+     264          43 :         TEST_CHECK (A == NULL) ;
+     265             : 
+     266         172 :         for (int trial = 0 ; trial <= 2 ; trial++)
+     267             :         {
+     268             :             // create the G->out_degree cached property and check it
+     269         129 :             OK (LAGraph_Cached_OutDegree (G, msg)) ;
+     270             :             GrB_Index n ;
+     271         129 :             OK (GrB_Matrix_nrows (&n, G->A)) ;
+     272         129 :             check_degree (G->out_degree, n, out_deg) ;
+     273             : 
+     274         129 :             if (trial == 2)
+     275             :             {
+     276             :                 // use G->AT to compute G->in_degree
+     277          43 :                 OK (LAGraph_DeleteCached (G, msg)) ;
+     278          43 :                 OK (LAGraph_Cached_AT (G, msg)) ;
+     279             :             }
+     280             : 
+     281             :             // create the G->in_degree cached property and check it
+     282         129 :             OK (LAGraph_Cached_InDegree (G, msg)) ;
+     283         129 :             OK (GrB_Matrix_ncols (&n, G->A)) ;
+     284         129 :             check_degree (G->in_degree, n, in_deg) ;
+     285             :         }
+     286             : 
+     287          43 :         OK (LAGraph_Delete (&G, msg)) ;
+     288             :     }
+     289             : 
+     290             :     // check error handling
+     291           1 :     int status = LAGraph_Cached_OutDegree (NULL, msg) ;
+     292           1 :     printf ("\nstatus: %d, msg: %s\n", status, msg) ;
+     293           1 :     TEST_CHECK (status == GrB_NULL_POINTER) ;
+     294           1 :     status = LAGraph_Cached_InDegree (NULL, msg) ;
+     295           1 :     printf ("status: %d, msg: %s\n", status, msg) ;
+     296           1 :     TEST_CHECK (status == GrB_NULL_POINTER) ;
+     297             : 
+     298           1 :     teardown ( ) ;
+     299           1 : }
+     300             : 
+     301             : //-----------------------------------------------------------------------------
+     302             : // test_Cached_Degree_brutal
+     303             : //-----------------------------------------------------------------------------
+     304             : 
+     305             : #if LAGRAPH_SUITESPARSE
+     306           1 : void test_Cached_Degree_brutal (void)
+     307             : {
+     308           1 :     OK (LG_brutal_setup (msg)) ;
+     309             : 
+     310           1 :     for (int k = 0 ; ; k++)
+     311          43 :     {
+     312             : 
+     313             :         // load the matrix as A
+     314          44 :         const char *aname = files [k].name ;
+     315          44 :         if (strlen (aname) == 0) break;
+     316          43 :         const int *out_deg = files [k].out_deg ;
+     317          43 :         const int *in_deg = files [k].in_deg ;
+     318          43 :         TEST_CASE (aname) ;
+     319          43 :         snprintf (filename, LEN, LG_DATA_DIR "%s", aname) ;
+     320          43 :         FILE *f = fopen (filename, "r") ;
+     321          43 :         TEST_CHECK (f != NULL) ;
+     322          43 :         OK (LAGraph_MMRead (&A, f, msg)) ;
+     323          43 :         OK (fclose (f)) ;
+     324          43 :         TEST_MSG ("Loading of adjacency matrix failed") ;
+     325             : 
+     326             :         // construct the graph G with adjacency matrix A
+     327          43 :         OK (LAGraph_New (&G, &A, LAGraph_ADJACENCY_DIRECTED, msg)) ;
+     328          43 :         TEST_CHECK (A == NULL) ;
+     329             : 
+     330         172 :         for (int trial = 0 ; trial <= 2 ; trial++)
+     331             :         {
+     332             :             // create the G->out_degree cached property and check it
+     333         425 :             LG_BRUTAL (LAGraph_Cached_OutDegree (G, msg)) ;
+     334             :             GrB_Index n ;
+     335         129 :             OK (GrB_Matrix_nrows (&n, G->A)) ;
+     336         129 :             check_degree (G->out_degree, n, out_deg) ;
+     337             : 
+     338         129 :             if (trial == 2)
+     339             :             {
+     340             :                 // use G->AT to compute G->in_degree
+     341          43 :                 OK (LAGraph_DeleteCached (G, msg)) ;
+     342          43 :                 OK (LAGraph_Cached_AT (G, msg)) ;
+     343             :             }
+     344             : 
+     345             :             // create the G->in_degree cached property and check it
+     346         732 :             LG_BRUTAL (LAGraph_Cached_InDegree (G, msg)) ;
+     347         129 :             OK (GrB_Matrix_ncols (&n, G->A)) ;
+     348         129 :             check_degree (G->in_degree, n, in_deg) ;
+     349             :         }
+     350             : 
+     351          43 :         OK (LAGraph_Delete (&G, msg)) ;
+     352             :     }
+     353             : 
+     354           1 :     OK (LG_brutal_teardown (msg)) ;
+     355           1 : }
+     356             : #endif
+     357             : 
+     358             : //-----------------------------------------------------------------------------
+     359             : // TEST_LIST: the list of tasks for this entire test
+     360             : //-----------------------------------------------------------------------------
+     361             : 
+     362             : TEST_LIST =
+     363             : {
+     364             :     { "test_Degree", test_Cached_Degree },
+     365             :     #if LAGRAPH_SUITESPARSE
+     366             :     { "test_Degree_brutal", test_Cached_Degree_brutal },
+     367             :     #endif
+     368             :     { NULL, NULL }
+     369             : } ;
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_Cached_NDiag.c.func-sort-c.html b/src/test/test_Cached_NDiag.c.func-sort-c.html new file mode 100644 index 0000000000..480fe7a166 --- /dev/null +++ b/src/test/test_Cached_NDiag.c.func-sort-c.html @@ -0,0 +1,88 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_Cached_NDiag.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_Cached_NDiag.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:4545100.0 %
Date:2024-08-29 20:08:04Functions:44100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
setup1
teardown1
test_Cached_NSelfEdges1
test_Cached_NSelfEdges_brutal1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_Cached_NDiag.c.func.html b/src/test/test_Cached_NDiag.c.func.html new file mode 100644 index 0000000000..68e34d1dc2 --- /dev/null +++ b/src/test/test_Cached_NDiag.c.func.html @@ -0,0 +1,88 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_Cached_NDiag.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_Cached_NDiag.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:4545100.0 %
Date:2024-08-29 20:08:04Functions:44100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
setup1
teardown1
test_Cached_NSelfEdges1
test_Cached_NSelfEdges_brutal1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_Cached_NDiag.c.gcov.html b/src/test/test_Cached_NDiag.c.gcov.html new file mode 100644 index 0000000000..a950070d5b --- /dev/null +++ b/src/test/test_Cached_NDiag.c.gcov.html @@ -0,0 +1,299 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_Cached_NDiag.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_Cached_NDiag.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:4545100.0 %
Date:2024-08-29 20:08:04Functions:44100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph/src/test/test_Cached_NSelfEdges.c:  test LAGraph_Cached_NSelfEdges
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include "LAGraph_test.h"
+      19             : 
+      20             : //------------------------------------------------------------------------------
+      21             : // global variables
+      22             : //------------------------------------------------------------------------------
+      23             : 
+      24             : LAGraph_Graph G = NULL ;
+      25             : GrB_Info info ;
+      26             : char msg [LAGRAPH_MSG_LEN] ;
+      27             : GrB_Matrix A = NULL ;
+      28             : #define LEN 512
+      29             : char filename [LEN+1] ;
+      30             : 
+      31             : //------------------------------------------------------------------------------
+      32             : // test matrices
+      33             : //------------------------------------------------------------------------------
+      34             : 
+      35             : typedef struct
+      36             : {
+      37             :     GrB_Index nself_edges ;
+      38             :     const char *name ;
+      39             : }
+      40             : matrix_info ;
+      41             : 
+      42             : const matrix_info files [ ] =
+      43             : {
+      44             :      0, "A.mtx",
+      45             :     14, "LFAT5.mtx",
+      46             :   2003, "bcsstk13.mtx",
+      47             : //   3, "complex.mtx",
+      48             :      0, "cover.mtx",
+      49             :      0, "cover_structure.mtx",
+      50             :   2500, "cryg2500.mtx",
+      51             :      3, "full.mtx",
+      52             :      4, "full_symmetric.mtx",
+      53             :   1138, "jagmesh7.mtx",
+      54             :      0, "karate.mtx",
+      55             :      0, "ldbc-cdlp-directed-example.mtx",
+      56             :      0, "ldbc-cdlp-undirected-example.mtx",
+      57             :      0, "ldbc-directed-example-bool.mtx",
+      58             :      0, "ldbc-directed-example-unweighted.mtx",
+      59             :      0, "ldbc-directed-example.mtx",
+      60             :      0, "ldbc-undirected-example-bool.mtx",
+      61             :      0, "ldbc-undirected-example-unweighted.mtx",
+      62             :      0, "ldbc-undirected-example.mtx",
+      63             :      0, "ldbc-wcc-example.mtx",
+      64             :      0, "matrix_bool.mtx",
+      65             :      0, "matrix_fp32.mtx",
+      66             :      0, "matrix_fp32_structure.mtx",
+      67             :      0, "matrix_fp64.mtx",
+      68             :      0, "matrix_int16.mtx",
+      69             :      0, "matrix_int32.mtx",
+      70             :      0, "matrix_int64.mtx",
+      71             :      0, "matrix_int8.mtx",
+      72             :      0, "matrix_uint16.mtx",
+      73             :      0, "matrix_uint32.mtx",
+      74             :      0, "matrix_uint64.mtx",
+      75             :      0, "matrix_uint8.mtx",
+      76             :      0, "msf1.mtx",
+      77             :      0, "msf2.mtx",
+      78             :      0, "msf3.mtx",
+      79             :   1000, "olm1000.mtx",
+      80             :      0, "structure.mtx",
+      81             :      0, "sample.mtx",
+      82             :      0, "sample2.mtx",
+      83             :      0, "skew_fp32.mtx",
+      84             :      0, "skew_fp64.mtx",
+      85             :      0, "skew_int16.mtx",
+      86             :      0, "skew_int32.mtx",
+      87             :      0, "skew_int64.mtx",
+      88             :      0, "skew_int8.mtx",
+      89             :      0, "tree-example.mtx",
+      90             :      2, "west0067.mtx",
+      91             :      2, "west0067_jumbled.mtx",
+      92             :      0, ""
+      93             : } ;
+      94             : 
+      95             : //------------------------------------------------------------------------------
+      96             : // setup: start a test
+      97             : //------------------------------------------------------------------------------
+      98             : 
+      99           1 : void setup (void)
+     100             : {
+     101           1 :     OK (LAGraph_Init (msg)) ;
+     102           1 : }
+     103             : 
+     104             : //------------------------------------------------------------------------------
+     105             : // teardown: finalize a test
+     106             : //------------------------------------------------------------------------------
+     107             : 
+     108           1 : void teardown (void)
+     109             : {
+     110           1 :     OK (LAGraph_Finalize (msg)) ;
+     111           1 : }
+     112             : 
+     113             : //------------------------------------------------------------------------------
+     114             : // test_Cached_NSelfEdges:  test LAGraph_Cached_NSelfEdges
+     115             : //------------------------------------------------------------------------------
+     116             : 
+     117           1 : void test_Cached_NSelfEdges (void)
+     118             : {
+     119             : 
+     120             :     //--------------------------------------------------------------------------
+     121             :     // start up the test
+     122             :     //--------------------------------------------------------------------------
+     123             : 
+     124           1 :     setup ( ) ;
+     125             : 
+     126           1 :     for (int k = 0 ; ; k++)
+     127          47 :     {
+     128             : 
+     129             :         //----------------------------------------------------------------------
+     130             :         // load in the kth file
+     131             :         //----------------------------------------------------------------------
+     132             : 
+     133          48 :         const char *aname = files [k].name ;
+     134          48 :         if (strlen (aname) == 0) break;
+     135          47 :         TEST_CASE (aname) ;
+     136          47 :         snprintf (filename, LEN, LG_DATA_DIR "%s", aname) ;
+     137          47 :         FILE *f = fopen (filename, "r") ;
+     138          47 :         TEST_CHECK (f != NULL) ;
+     139          47 :         OK (LAGraph_MMRead (&A, f, msg)) ;
+     140          47 :         OK (fclose (f)) ;
+     141          47 :         TEST_MSG ("Failed to load %s\n", aname) ;
+     142             : 
+     143             :         //----------------------------------------------------------------------
+     144             :         // construct a directed graph and count self-edges
+     145             :         //----------------------------------------------------------------------
+     146             : 
+     147          47 :         OK (LAGraph_New (&G, &A, LAGraph_ADJACENCY_DIRECTED, msg)) ;
+     148          47 :         OK (LAGraph_Cached_NSelfEdges (G, msg)) ;
+     149          47 :         TEST_CHECK (G->nself_edges == files [k].nself_edges) ;
+     150             : 
+     151             :         //----------------------------------------------------------------------
+     152             :         // free the graph
+     153             :         //----------------------------------------------------------------------
+     154             : 
+     155          47 :         OK (LAGraph_Delete (&G, msg)) ;
+     156             :     }
+     157             : 
+     158           1 :     TEST_CHECK (LAGraph_Cached_NSelfEdges (NULL, msg) == GrB_NULL_POINTER) ;
+     159             : 
+     160             :     //--------------------------------------------------------------------------
+     161             :     // finish the test
+     162             :     //--------------------------------------------------------------------------
+     163             : 
+     164           1 :     teardown ( ) ;
+     165           1 : }
+     166             : 
+     167             : //------------------------------------------------------------------------------
+     168             : // test_Cached_NSelfEdges_brutal
+     169             : //------------------------------------------------------------------------------
+     170             : 
+     171             : #if LAGRAPH_SUITESPARSE
+     172           1 : void test_Cached_NSelfEdges_brutal (void)
+     173             : {
+     174           1 :     OK (LG_brutal_setup (msg)) ;
+     175             : 
+     176           1 :     for (int k = 0 ; ; k++)
+     177          47 :     {
+     178             : 
+     179             :         //----------------------------------------------------------------------
+     180             :         // load in the kth file
+     181             :         //----------------------------------------------------------------------
+     182             : 
+     183          48 :         const char *aname = files [k].name ;
+     184          48 :         if (strlen (aname) == 0) break;
+     185          47 :         TEST_CASE (aname) ;
+     186          47 :         snprintf (filename, LEN, LG_DATA_DIR "%s", aname) ;
+     187          47 :         FILE *f = fopen (filename, "r") ;
+     188          47 :         TEST_CHECK (f != NULL) ;
+     189          47 :         OK (LAGraph_MMRead (&A, f, msg)) ;
+     190          47 :         OK (fclose (f)) ;
+     191          47 :         TEST_MSG ("Failed to load %s\n", aname) ;
+     192             : 
+     193             :         //----------------------------------------------------------------------
+     194             :         // construct a directed graph and count self-edges
+     195             :         //----------------------------------------------------------------------
+     196             : 
+     197          47 :         OK (LAGraph_New (&G, &A, LAGraph_ADJACENCY_DIRECTED, msg)) ;
+     198         493 :         LG_BRUTAL (LAGraph_Cached_NSelfEdges (G, msg)) ;
+     199          47 :         TEST_CHECK (G->nself_edges == files [k].nself_edges) ;
+     200             : 
+     201             :         //----------------------------------------------------------------------
+     202             :         // free the graph
+     203             :         //----------------------------------------------------------------------
+     204             : 
+     205          47 :         OK (LAGraph_Delete (&G, msg)) ;
+     206             :     }
+     207             : 
+     208           1 :     OK (LG_brutal_teardown (msg)) ;
+     209           1 : }
+     210             : #endif
+     211             : 
+     212             : //-----------------------------------------------------------------------------
+     213             : // TEST_LIST: the list of tasks for this entire test
+     214             : //-----------------------------------------------------------------------------
+     215             : 
+     216             : TEST_LIST =
+     217             : {
+     218             :     { "NSelfEdges", test_Cached_NSelfEdges },
+     219             :     #if LAGRAPH_SUITESPARSE
+     220             :     { "NSelfEdges_brutal", test_Cached_NSelfEdges_brutal },
+     221             :     #endif
+     222             :     { NULL, NULL }
+     223             : } ;
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_Cached_SymmetricStructure.c.func-sort-c.html b/src/test/test_Cached_SymmetricStructure.c.func-sort-c.html new file mode 100644 index 0000000000..2a0364a2a1 --- /dev/null +++ b/src/test/test_Cached_SymmetricStructure.c.func-sort-c.html @@ -0,0 +1,88 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_Cached_SymmetricStructure.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_Cached_SymmetricStructure.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:7979100.0 %
Date:2024-08-29 20:08:04Functions:44100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
setup1
teardown1
test_Cached_Symmetric_Structure1
test_Cached_Symmetric_Structure_brutal1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_Cached_SymmetricStructure.c.func.html b/src/test/test_Cached_SymmetricStructure.c.func.html new file mode 100644 index 0000000000..02a4382e29 --- /dev/null +++ b/src/test/test_Cached_SymmetricStructure.c.func.html @@ -0,0 +1,88 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_Cached_SymmetricStructure.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_Cached_SymmetricStructure.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:7979100.0 %
Date:2024-08-29 20:08:04Functions:44100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
setup1
teardown1
test_Cached_Symmetric_Structure1
test_Cached_Symmetric_Structure_brutal1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_Cached_SymmetricStructure.c.gcov.html b/src/test/test_Cached_SymmetricStructure.c.gcov.html new file mode 100644 index 0000000000..edabda39f5 --- /dev/null +++ b/src/test/test_Cached_SymmetricStructure.c.gcov.html @@ -0,0 +1,365 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_Cached_SymmetricStructure.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_Cached_SymmetricStructure.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:7979100.0 %
Date:2024-08-29 20:08:04Functions:44100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph/src/test/test_Cached_Symmetric_Structure.c
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include "LAGraph_test.h"
+      19             : 
+      20             : //------------------------------------------------------------------------------
+      21             : // global variables
+      22             : //------------------------------------------------------------------------------
+      23             : 
+      24             : LAGraph_Graph G = NULL ;
+      25             : char msg [LAGRAPH_MSG_LEN] ;
+      26             : GrB_Matrix A = NULL ;
+      27             : #define LEN 512
+      28             : char filename [LEN+1] ;
+      29             : 
+      30             : //------------------------------------------------------------------------------
+      31             : // setup: start a test
+      32             : //------------------------------------------------------------------------------
+      33             : 
+      34           1 : void setup (void)
+      35             : {
+      36           1 :     OK (LAGraph_Init (msg)) ;
+      37           1 : }
+      38             : 
+      39             : //------------------------------------------------------------------------------
+      40             : // teardown: finalize a test
+      41             : //------------------------------------------------------------------------------
+      42             : 
+      43           1 : void teardown (void)
+      44             : {
+      45           1 :     OK (LAGraph_Finalize (msg)) ;
+      46           1 : }
+      47             : 
+      48             : //------------------------------------------------------------------------------
+      49             : // test_Cached_Symmetric_Structure:
+      50             : //------------------------------------------------------------------------------
+      51             : 
+      52             : typedef struct
+      53             : {
+      54             :     bool symmetric_structure ;
+      55             :     bool symmetric_values ;
+      56             :     const char *name ;
+      57             : }
+      58             : matrix_info ;
+      59             : 
+      60             : const matrix_info files [ ] =
+      61             : {
+      62             :     1, 1, "A.mtx",
+      63             :     1, 1, "LFAT5.mtx",
+      64             :     1, 1, "bcsstk13.mtx",
+      65             :     1, 0, "comments_full.mtx",
+      66             :     0, 0, "comments_west0067.mtx",
+      67             : //  1, 0, "complex.mtx",
+      68             :     0, 0, "cover.mtx",
+      69             :     0, 0, "cover_structure.mtx",
+      70             :     0, 0, "cryg2500.mtx",
+      71             :     0, 0, "empty.mtx",
+      72             :     1, 0, "full.mtx",
+      73             :     1, 1, "full_symmetric.mtx",
+      74             :     1, 1, "jagmesh7.mtx",
+      75             :     1, 1, "karate.mtx",
+      76             :     0, 0, "ldbc-cdlp-directed-example.mtx",
+      77             :     1, 1, "ldbc-cdlp-undirected-example.mtx",
+      78             :     0, 0, "ldbc-directed-example-bool.mtx",
+      79             :     0, 0, "ldbc-directed-example-unweighted.mtx",
+      80             :     0, 0, "ldbc-directed-example.mtx",
+      81             :     1, 1, "ldbc-undirected-example-bool.mtx",
+      82             :     1, 1, "ldbc-undirected-example-unweighted.mtx",
+      83             :     1, 1, "ldbc-undirected-example.mtx",
+      84             :     1, 1, "ldbc-wcc-example.mtx",
+      85             :     0, 0, "lp_afiro.mtx",
+      86             :     0, 0, "lp_afiro_structure.mtx",
+      87             :     0, 0, "matrix_bool.mtx",
+      88             :     0, 0, "matrix_fp32.mtx",
+      89             :     0, 0, "matrix_fp32_structure.mtx",
+      90             :     0, 0, "matrix_fp64.mtx",
+      91             :     0, 0, "matrix_int16.mtx",
+      92             :     0, 0, "matrix_int32.mtx",
+      93             :     0, 0, "matrix_int64.mtx",
+      94             :     0, 0, "matrix_int8.mtx",
+      95             :     0, 0, "matrix_uint16.mtx",
+      96             :     0, 0, "matrix_uint32.mtx",
+      97             :     0, 0, "matrix_uint64.mtx",
+      98             :     0, 0, "matrix_uint8.mtx",
+      99             :     0, 0, "msf1.mtx",
+     100             :     0, 0, "msf2.mtx",
+     101             :     0, 0, "msf3.mtx",
+     102             :     0, 0, "olm1000.mtx",
+     103             :     0, 0, "structure.mtx",
+     104             :     0, 0, "sample.mtx",
+     105             :     1, 1, "sample2.mtx",
+     106             :     1, 0, "skew_fp32.mtx",
+     107             :     1, 0, "skew_fp64.mtx",
+     108             :     1, 0, "skew_int16.mtx",
+     109             :     1, 0, "skew_int32.mtx",
+     110             :     1, 0, "skew_int64.mtx",
+     111             :     1, 0, "skew_int8.mtx",
+     112             :     0, 0, "sources_7.mtx",
+     113             :     1, 1, "tree-example.mtx",
+     114             :     0, 0, "west0067.mtx",
+     115             :     0, 0, "west0067_jumbled.mtx",
+     116             :     0, 0, ""
+     117             : } ;
+     118             : 
+     119           1 : void test_Cached_Symmetric_Structure (void)
+     120             : {
+     121           1 :     setup ( ) ;
+     122             : 
+     123           1 :     for (int k = 0 ; ; k++)
+     124          53 :     {
+     125             : 
+     126             :         // load the matrix as A
+     127          54 :         const char *aname = files [k].name ;
+     128          54 :         bool sym_structure = files [k].symmetric_structure ;
+     129          54 :         bool sym_values  = files [k].symmetric_values ;
+     130          54 :         if (strlen (aname) == 0) break;
+     131             :         // printf ("%s:\n", aname) ;
+     132          53 :         TEST_CASE (aname) ;
+     133          53 :         snprintf (filename, LEN, LG_DATA_DIR "%s", aname) ;
+     134          53 :         FILE *f = fopen (filename, "r") ;
+     135          53 :         TEST_CHECK (f != NULL) ;
+     136          53 :         OK (LAGraph_MMRead (&A, f, msg)) ;
+     137          53 :         OK (fclose (f)) ;
+     138          53 :         TEST_MSG ("Loading of adjacency matrix failed") ;
+     139             : 
+     140             :         // construct a directed graph G with adjacency matrix A
+     141          53 :         OK (LAGraph_New (&G, &A, LAGraph_ADJACENCY_DIRECTED, msg)) ;
+     142          53 :         TEST_CHECK (A == NULL) ;
+     143             : 
+     144             :         // compute the is_symmetric_structure cached property
+     145          53 :         OK (LAGraph_Cached_IsSymmetricStructure (G, msg)) ;
+     146             : 
+     147             :         // check the result
+     148          53 :         if (sym_structure)
+     149             :         {
+     150          21 :             TEST_CHECK (G->is_symmetric_structure == LAGraph_TRUE) ;
+     151             :         }
+     152             :         else
+     153             :         {
+     154          32 :             TEST_CHECK (G->is_symmetric_structure == LAGraph_FALSE) ;
+     155             :         }
+     156             : 
+     157             :         // delete all cached properties
+     158          53 :         OK (LAGraph_DeleteCached (G, msg)) ;
+     159             : 
+     160             :         // try again, but precompute G->AT
+     161          53 :         OK (LAGraph_Cached_AT (G, msg)) ;
+     162          53 :         OK (LAGraph_Cached_IsSymmetricStructure (G, msg)) ;
+     163             : 
+     164             :         // check the result
+     165          53 :         if (sym_structure)
+     166             :         {
+     167          21 :             TEST_CHECK (G->is_symmetric_structure == LAGraph_TRUE) ;
+     168             :         }
+     169             :         else
+     170             :         {
+     171          32 :             TEST_CHECK (G->is_symmetric_structure == LAGraph_FALSE) ;
+     172             :         }
+     173             : 
+     174             :         // delete all cached properties
+     175          53 :         OK (LAGraph_DeleteCached (G, msg)) ;
+     176             : 
+     177             :         // change the graph to directed, if matrix is symmetric
+     178          53 :         if (sym_values)
+     179             :         {
+     180          13 :             G->kind = LAGraph_ADJACENCY_UNDIRECTED ;
+     181             :             // recompute the symmetry cached property
+     182          13 :             OK (LAGraph_Cached_IsSymmetricStructure (G, msg)) ;
+     183          13 :             TEST_CHECK (G->is_symmetric_structure == LAGraph_TRUE) ;
+     184             :         }
+     185             : 
+     186          53 :         OK (LAGraph_Delete (&G, msg)) ;
+     187             : 
+     188             :     }
+     189             : 
+     190             :     // check error handling
+     191           1 :     int status = LAGraph_Cached_IsSymmetricStructure (NULL, msg) ;
+     192           1 :     printf ("\nstatus: %d, msg: %s\n", status, msg) ;
+     193           1 :     TEST_CHECK (status == GrB_NULL_POINTER) ;
+     194             : 
+     195           1 :     teardown ( ) ;
+     196           1 : }
+     197             : 
+     198             : //-----------------------------------------------------------------------------
+     199             : // test_Cached_Symmetric_Structure_brutal
+     200             : //-----------------------------------------------------------------------------
+     201             : 
+     202             : #if LAGRAPH_SUITESPARSE
+     203           1 : void test_Cached_Symmetric_Structure_brutal (void)
+     204             : {
+     205           1 :     OK (LG_brutal_setup (msg)) ;
+     206             : 
+     207           1 :     for (int k = 0 ; ; k++)
+     208          53 :     {
+     209             : 
+     210             :         // load the matrix as A
+     211          54 :         const char *aname = files [k].name ;
+     212          54 :         bool sym_structure = files [k].symmetric_structure ;
+     213          54 :         bool sym_values  = files [k].symmetric_values ;
+     214          54 :         if (strlen (aname) == 0) break;
+     215             :         // printf ("%s:\n", aname) ;
+     216          53 :         TEST_CASE (aname) ;
+     217          53 :         snprintf (filename, LEN, LG_DATA_DIR "%s", aname) ;
+     218          53 :         FILE *f = fopen (filename, "r") ;
+     219          53 :         TEST_CHECK (f != NULL) ;
+     220          53 :         OK (LAGraph_MMRead (&A, f, msg)) ;
+     221          53 :         OK (fclose (f)) ;
+     222          53 :         TEST_MSG ("Loading of adjacency matrix failed") ;
+     223             : 
+     224             :         // construct a directed graph G with adjacency matrix A
+     225          53 :         OK (LAGraph_New (&G, &A, LAGraph_ADJACENCY_DIRECTED, msg)) ;
+     226          53 :         TEST_CHECK (A == NULL) ;
+     227             : 
+     228             :         // compute the is_symmetric_structure cached property
+     229         372 :         LG_BRUTAL (LAGraph_Cached_IsSymmetricStructure (G, msg)) ;
+     230             : 
+     231             :         // check the result
+     232          53 :         if (sym_structure)
+     233             :         {
+     234          21 :             TEST_CHECK (G->is_symmetric_structure == LAGraph_TRUE) ;
+     235             :         }
+     236             :         else
+     237             :         {
+     238          32 :             TEST_CHECK (G->is_symmetric_structure == LAGraph_FALSE) ;
+     239             :         }
+     240             : 
+     241             :         // delete all cached properties
+     242          53 :         OK (LAGraph_DeleteCached (G, msg)) ;
+     243             : 
+     244             :         // try again, but precompute G->AT
+     245         335 :         LG_BRUTAL (LAGraph_Cached_AT (G, msg)) ;
+     246         329 :         LG_BRUTAL (LAGraph_Cached_IsSymmetricStructure (G, msg)) ;
+     247             : 
+     248             :         // check the result
+     249          53 :         if (sym_structure)
+     250             :         {
+     251          21 :             TEST_CHECK (G->is_symmetric_structure == LAGraph_TRUE) ;
+     252             :         }
+     253             :         else
+     254             :         {
+     255          32 :             TEST_CHECK (G->is_symmetric_structure == LAGraph_FALSE) ;
+     256             :         }
+     257             : 
+     258             :         // delete all cached properties
+     259          53 :         OK (LAGraph_DeleteCached (G, msg)) ;
+     260             : 
+     261             :         // change the graph to directed, if matrix is symmetric
+     262          53 :         if (sym_values)
+     263             :         {
+     264          13 :             G->kind = LAGraph_ADJACENCY_UNDIRECTED ;
+     265             :             // recompute the symmetry cached property
+     266          13 :             LG_BRUTAL (LAGraph_Cached_IsSymmetricStructure (G, msg)) ;
+     267          13 :             TEST_CHECK (G->is_symmetric_structure == LAGraph_TRUE) ;
+     268             :         }
+     269             : 
+     270          53 :         OK (LAGraph_Delete (&G, msg)) ;
+     271             :     }
+     272             : 
+     273           1 :     OK (LG_brutal_teardown (msg)) ;
+     274           1 : }
+     275             : #endif
+     276             : 
+     277             : //-----------------------------------------------------------------------------
+     278             : // TEST_LIST: the list of tasks for this entire test
+     279             : //-----------------------------------------------------------------------------
+     280             : 
+     281             : TEST_LIST =
+     282             : {
+     283             :     { "test_Symmetric_Structure", test_Cached_Symmetric_Structure },
+     284             :     #if LAGRAPH_SUITESPARSE
+     285             :     { "test_Symmetric_Structure_brutal",
+     286             :         test_Cached_Symmetric_Structure_brutal },
+     287             :     #endif
+     288             :     { NULL, NULL }
+     289             : } ;
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_CheckGraph.c.func-sort-c.html b/src/test/test_CheckGraph.c.func-sort-c.html new file mode 100644 index 0000000000..0c3ed461a1 --- /dev/null +++ b/src/test/test_CheckGraph.c.func-sort-c.html @@ -0,0 +1,92 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_CheckGraph.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_CheckGraph.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:136136100.0 %
Date:2024-08-29 20:08:04Functions:55100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_CheckGraph1
test_CheckGraph_brutal1
test_CheckGraph_failures1
setup2
teardown2
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_CheckGraph.c.func.html b/src/test/test_CheckGraph.c.func.html new file mode 100644 index 0000000000..fbff521289 --- /dev/null +++ b/src/test/test_CheckGraph.c.func.html @@ -0,0 +1,92 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_CheckGraph.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_CheckGraph.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:136136100.0 %
Date:2024-08-29 20:08:04Functions:55100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
setup2
teardown2
test_CheckGraph1
test_CheckGraph_brutal1
test_CheckGraph_failures1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_CheckGraph.c.gcov.html b/src/test/test_CheckGraph.c.gcov.html new file mode 100644 index 0000000000..f2d2e0a179 --- /dev/null +++ b/src/test/test_CheckGraph.c.gcov.html @@ -0,0 +1,377 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_CheckGraph.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_CheckGraph.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:136136100.0 %
Date:2024-08-29 20:08:04Functions:55100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph/src/test/test_CheckGraph.c:  test LAGraph_CheckGraph
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include "LAGraph_test.h"
+      19             : 
+      20             : //------------------------------------------------------------------------------
+      21             : // global variables
+      22             : //------------------------------------------------------------------------------
+      23             : 
+      24             : LAGraph_Graph G = NULL ;
+      25             : char msg [LAGRAPH_MSG_LEN] ;
+      26             : GrB_Matrix A = NULL, B_bool = NULL, B_int32 = NULL ;
+      27             : GrB_Vector d_int64 = NULL, d_bool = NULL ;
+      28             : #define LEN 512
+      29             : char filename [LEN+1] ;
+      30             : 
+      31             : //------------------------------------------------------------------------------
+      32             : // setup: start a test
+      33             : //------------------------------------------------------------------------------
+      34             : 
+      35           2 : void setup (void)
+      36             : {
+      37           2 :     OK (LAGraph_Init (msg)) ;
+      38           2 : }
+      39             : 
+      40             : //------------------------------------------------------------------------------
+      41             : // teardown: finalize a test
+      42             : //------------------------------------------------------------------------------
+      43             : 
+      44           2 : void teardown (void)
+      45             : {
+      46           2 :     OK (LAGraph_Finalize (msg)) ;
+      47           2 : }
+      48             : 
+      49             : //------------------------------------------------------------------------------
+      50             : // test_CheckGraph:  test LAGraph_CheckGraph
+      51             : //------------------------------------------------------------------------------
+      52             : 
+      53             : typedef struct
+      54             : {
+      55             :     LAGraph_Kind kind ;
+      56             :     const char *name ;
+      57             : }
+      58             : matrix_info ;
+      59             : 
+      60             : const matrix_info files [ ] =
+      61             : {
+      62             :     LAGraph_ADJACENCY_DIRECTED,   "cover.mtx",
+      63             :     LAGraph_ADJACENCY_DIRECTED,   "ldbc-directed-example.mtx",
+      64             :     LAGraph_ADJACENCY_UNDIRECTED, "ldbc-undirected-example.mtx",
+      65             :     LAGRAPH_UNKNOWN,              ""
+      66             : } ;
+      67             : 
+      68           1 : void test_CheckGraph (void)
+      69             : {
+      70           1 :     setup ( ) ;
+      71             : 
+      72           1 :     for (int k = 0 ; ; k++)
+      73           3 :     {
+      74             : 
+      75             :         // load the adjacency matrix as A
+      76           4 :         const char *aname = files [k].name ;
+      77           4 :         LAGraph_Kind kind = files [k].kind ;
+      78           4 :         if (strlen (aname) == 0) break;
+      79           3 :         TEST_CASE (aname) ;
+      80           3 :         snprintf (filename, LEN, LG_DATA_DIR "%s", aname) ;
+      81           3 :         FILE *f = fopen (filename, "r") ;
+      82           3 :         TEST_CHECK (f != NULL) ;
+      83           3 :         OK (LAGraph_MMRead (&A, f, msg)) ;
+      84           3 :         OK (fclose (f)) ;
+      85           3 :         TEST_MSG ("Loading of adjacency matrix failed") ;
+      86             : 
+      87             :         // create the graph
+      88           3 :         OK (LAGraph_New (&G, &A, kind, msg)) ;
+      89           3 :         TEST_CHECK (A == NULL) ;    // A has been moved into G->A
+      90             : 
+      91             :         // check the graph
+      92           3 :         OK (LAGraph_CheckGraph (G, msg)) ;
+      93           3 :         TEST_CHECK (G->kind == kind) ;
+      94           3 :         if (kind == LAGraph_ADJACENCY_DIRECTED)
+      95             :         {
+      96           2 :             TEST_CHECK (G->is_symmetric_structure == LAGRAPH_UNKNOWN) ;
+      97             :         }
+      98             :         else
+      99             :         {
+     100           1 :             TEST_CHECK (G->is_symmetric_structure == LAGraph_TRUE) ;
+     101             :         }
+     102             : 
+     103             :         // create its cached properties
+     104           3 :         int ok_result = (kind == LAGraph_ADJACENCY_UNDIRECTED) ?
+     105           3 :             LAGRAPH_CACHE_NOT_NEEDED : GrB_SUCCESS ;
+     106           3 :         int result = LAGraph_Cached_AT (G, msg) ;
+     107           3 :         OK (LAGraph_CheckGraph (G, msg)) ;
+     108           3 :         TEST_CHECK (result == ok_result) ;
+     109             : 
+     110           3 :         OK (LAGraph_Cached_OutDegree (G, msg)) ;
+     111           3 :         OK (LAGraph_CheckGraph (G, msg)) ;
+     112             : 
+     113           3 :         result = LAGraph_Cached_InDegree (G, msg) ;
+     114           3 :         TEST_CHECK (result == ok_result) ;
+     115           3 :         OK (LAGraph_CheckGraph (G, msg)) ;
+     116             : 
+     117             :         // free the graph
+     118           3 :         OK (LAGraph_Delete (&G, msg)) ;
+     119           3 :         TEST_CHECK (G == NULL) ;
+     120             : 
+     121             :     }
+     122             : 
+     123           1 :     teardown ( ) ;
+     124           1 : }
+     125             : 
+     126             : //------------------------------------------------------------------------------
+     127             : // test_CheckGraph_failures:  test error handling of LAGraph_CheckGraph
+     128             : //------------------------------------------------------------------------------
+     129             : 
+     130           1 : void test_CheckGraph_failures (void)
+     131             : {
+     132           1 :     setup ( ) ;
+     133             : 
+     134           1 :     printf ("\nTesting LAGraph_CheckGraph error handling:\n") ;
+     135             : 
+     136             :     // construct an invalid graph with a rectangular adjacency matrix
+     137           1 :     TEST_CASE ("lp_afiro") ;
+     138           1 :     FILE *f = fopen (LG_DATA_DIR "lp_afiro.mtx", "r") ;
+     139           1 :     TEST_CHECK (f != NULL) ;
+     140           1 :     OK (LAGraph_MMRead (&A, f, msg)) ;
+     141           1 :     OK (fclose (f)) ;
+     142           1 :     TEST_MSG ("Loading of lp_afiro.mtx failed") ;
+     143             : 
+     144             :     // create an invalid graph
+     145           1 :     OK (LAGraph_New (&G, &A, LAGraph_ADJACENCY_DIRECTED, msg)) ;
+     146           1 :     TEST_CHECK (A == NULL) ;    // A has been moved into G->A
+     147             : 
+     148             :     // adjacency matrix invalid
+     149           1 :     TEST_CHECK (LAGraph_CheckGraph (G, msg) == LAGRAPH_INVALID_GRAPH) ;
+     150           1 :     printf ("msg: %s\n", msg) ;
+     151             : 
+     152             :     // free the graph
+     153           1 :     OK (LAGraph_Delete (&G, msg)) ;
+     154           1 :     TEST_CHECK (G == NULL) ;
+     155             : 
+     156             :     // load a valid adjacency matrix
+     157           1 :     TEST_CASE ("cover") ;
+     158           1 :     f = fopen (LG_DATA_DIR "cover.mtx", "r") ;
+     159           1 :     TEST_CHECK (f != NULL) ;
+     160           1 :     OK (LAGraph_MMRead (&A, f, msg)) ;
+     161           1 :     OK (fclose (f)) ;
+     162           1 :     TEST_MSG ("Loading of cover.mtx failed") ;
+     163             : 
+     164             :     // create an valid graph
+     165           1 :     OK (LAGraph_New (&G, &A, LAGraph_ADJACENCY_DIRECTED, msg)) ;
+     166           1 :     TEST_CHECK (A == NULL) ;    // A has been moved into G->A
+     167           1 :     OK (LAGraph_CheckGraph (G, msg)) ;
+     168             : 
+     169           1 :     OK (GrB_Vector_new (&d_bool,  GrB_BOOL, 7)) ;
+     170           1 :     OK (GrB_Vector_new (&d_int64, GrB_INT64, 1000)) ;
+     171           1 :     OK (GrB_Matrix_new (&B_bool,  GrB_INT64, 7, 7)) ;
+     172           1 :     OK (GrB_Matrix_new (&B_int32, GrB_INT32, 3, 4)) ;
+     173             : 
+     174             :     // G->AT has the right type, but wrong size
+     175           1 :     G->AT = B_int32 ;
+     176           1 :     TEST_CHECK (LAGraph_CheckGraph (G, msg) == LAGRAPH_INVALID_GRAPH) ;
+     177           1 :     printf ("msg: %s\n", msg) ;
+     178             : 
+     179             :     // G->AT has the right size, but wrong type
+     180           1 :     G->AT = B_bool ;
+     181           1 :     TEST_CHECK (LAGraph_CheckGraph (G, msg) == LAGRAPH_INVALID_GRAPH) ;
+     182           1 :     printf ("msg: %s\n", msg) ;
+     183             : 
+     184             :     #if LAGRAPH_SUITESPARSE
+     185             :     // G->AT must be by-row
+     186           1 :     OK (GxB_set (G->AT, GxB_FORMAT, GxB_BY_COL)) ;
+     187           1 :     TEST_CHECK (LAGraph_CheckGraph (G, msg) == LAGRAPH_INVALID_GRAPH) ;
+     188           1 :     printf ("msg: %s\n", msg) ;
+     189             :     #endif
+     190             : 
+     191           1 :     G->AT = NULL ;
+     192             : 
+     193             :     // G->out_degree has the right type, but wrong size
+     194           1 :     G->out_degree = d_int64 ;
+     195           1 :     TEST_CHECK (LAGraph_CheckGraph (G, msg) == LAGRAPH_INVALID_GRAPH) ;
+     196           1 :     printf ("msg: %s\n", msg) ;
+     197             : 
+     198             :     // G->out_degree has the right size, but wrong type
+     199           1 :     G->out_degree = d_bool ;
+     200           1 :     TEST_CHECK (LAGraph_CheckGraph (G, msg) == LAGRAPH_INVALID_GRAPH) ;
+     201           1 :     printf ("msg: %s\n", msg) ;
+     202             : 
+     203           1 :     G->out_degree = NULL ;
+     204             : 
+     205             :     // G->in_degree has the right type, but wrong size
+     206           1 :     G->in_degree = d_int64 ;
+     207           1 :     TEST_CHECK (LAGraph_CheckGraph (G, msg) == LAGRAPH_INVALID_GRAPH) ;
+     208           1 :     printf ("msg: %s\n", msg) ;
+     209             : 
+     210             :     // G->in_degree has the right size, but wrong type
+     211           1 :     G->in_degree = d_bool ;
+     212           1 :     TEST_CHECK (LAGraph_CheckGraph (G, msg) == LAGRAPH_INVALID_GRAPH) ;
+     213           1 :     printf ("msg: %s\n", msg) ;
+     214             : 
+     215           1 :     G->in_degree = NULL ;
+     216             : 
+     217             :     #if LAGRAPH_SUITESPARSE
+     218             :     // G->A must be by-row
+     219           1 :     OK (GxB_set (G->A, GxB_FORMAT, GxB_BY_COL)) ;
+     220           1 :     TEST_CHECK (LAGraph_CheckGraph (G, msg) == LAGRAPH_INVALID_GRAPH) ;
+     221           1 :     printf ("msg: %s\n", msg) ;
+     222             :     #endif
+     223             : 
+     224           1 :     GrB_free (&d_bool) ;
+     225           1 :     GrB_free (&d_int64) ;
+     226           1 :     GrB_free (&B_bool) ;
+     227           1 :     GrB_free (&B_int32) ;
+     228             : 
+     229             :     // mangle G->kind
+     230           1 :     G->kind = LAGRAPH_UNKNOWN ;
+     231           1 :     TEST_CHECK (LAGraph_CheckGraph (G, msg) == LAGRAPH_INVALID_GRAPH) ;
+     232           1 :     printf ("msg: %s\n", msg) ;
+     233           1 :     G->kind = LAGraph_ADJACENCY_DIRECTED ;
+     234             : 
+     235             :     // free the adjacency matrix
+     236           1 :     GrB_free (&(G->A)) ;
+     237           1 :     TEST_CHECK (G->A == NULL) ;
+     238             : 
+     239           1 :     int result = LAGraph_CheckGraph (G, msg) ;
+     240           1 :     printf ("result : %d msg: %s\n", result, msg) ;
+     241           1 :     TEST_CHECK (result == LAGRAPH_INVALID_GRAPH) ;
+     242             : 
+     243             :     // free the graph
+     244           1 :     OK (LAGraph_Delete (&G, msg)) ;
+     245           1 :     TEST_CHECK (G == NULL) ;
+     246             : 
+     247           1 :     TEST_CHECK (LAGraph_CheckGraph (NULL, msg) == GrB_NULL_POINTER) ;
+     248           1 :     printf ("msg: %s\n", msg) ;
+     249             : 
+     250           1 :     teardown ( ) ;
+     251           1 : }
+     252             : 
+     253             : //------------------------------------------------------------------------------
+     254             : // test_CheckGraph_brutal:
+     255             : //------------------------------------------------------------------------------
+     256             : 
+     257             : #if LAGRAPH_SUITESPARSE
+     258           1 : void test_CheckGraph_brutal (void)
+     259             : {
+     260           1 :     OK (LG_brutal_setup (msg)) ;
+     261             : 
+     262             :     // load a valid adjacency matrix
+     263           1 :     TEST_CASE ("karate") ;
+     264           1 :     FILE *f = fopen (LG_DATA_DIR "karate.mtx", "r") ;
+     265           1 :     TEST_CHECK (f != NULL) ;
+     266           1 :     OK (LAGraph_MMRead (&A, f, msg)) ;
+     267           1 :     OK (fclose (f)) ;
+     268           1 :     TEST_MSG ("Loading of karate.mtx failed") ;
+     269           1 :     printf ("\n") ;
+     270             : 
+     271             :     // create an valid graph
+     272           1 :     OK (LAGraph_New (&G, &A, LAGraph_ADJACENCY_UNDIRECTED, msg)) ;
+     273           1 :     TEST_CHECK (A == NULL) ;    // A has been moved into G->A
+     274           1 :     LG_BRUTAL_BURBLE (LAGraph_CheckGraph (G, msg)) ;
+     275             : 
+     276             :     // create its cached properties
+     277           1 :     LG_BRUTAL_BURBLE (LAGraph_Cached_AT (G, msg)) ;
+     278           1 :     LG_BRUTAL_BURBLE (LAGraph_CheckGraph (G, msg)) ;
+     279           7 :     LG_BRUTAL_BURBLE (LAGraph_Cached_OutDegree (G, msg)) ;
+     280           1 :     LG_BRUTAL_BURBLE (LAGraph_CheckGraph (G, msg)) ;
+     281           1 :     LG_BRUTAL_BURBLE (LAGraph_Cached_InDegree (G, msg)) ;
+     282           1 :     LG_BRUTAL_BURBLE (LAGraph_CheckGraph (G, msg)) ;
+     283           1 :     LG_BRUTAL_BURBLE (LAGraph_Delete (&G, msg)) ;
+     284             : 
+     285           1 :     OK (LG_brutal_teardown (msg)) ;
+     286           1 : }
+     287             : #endif
+     288             : 
+     289             : //-----------------------------------------------------------------------------
+     290             : // TEST_LIST: the list of tasks for this entire test
+     291             : //-----------------------------------------------------------------------------
+     292             : 
+     293             : TEST_LIST =
+     294             : {
+     295             :     { "CheckGraph", test_CheckGraph },
+     296             :     { "CheckGraph_failures", test_CheckGraph_failures },
+     297             :     #if LAGRAPH_SUITESPARSE
+     298             :     { "CheckGraph_brutal", test_CheckGraph_brutal },
+     299             :     #endif
+     300             :     { NULL, NULL }
+     301             : } ;
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_ConnectedComponents.c.func-sort-c.html b/src/test/test_ConnectedComponents.c.func-sort-c.html new file mode 100644 index 0000000000..878422d484 --- /dev/null +++ b/src/test/test_ConnectedComponents.c.func-sort-c.html @@ -0,0 +1,88 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_ConnectedComponents.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_ConnectedComponents.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:115115100.0 %
Date:2024-08-29 20:08:04Functions:44100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_cc_brutal1
test_cc_errors1
test_cc_matrices1
count_connected_components97
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_ConnectedComponents.c.func.html b/src/test/test_ConnectedComponents.c.func.html new file mode 100644 index 0000000000..550a5450ac --- /dev/null +++ b/src/test/test_ConnectedComponents.c.func.html @@ -0,0 +1,88 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_ConnectedComponents.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_ConnectedComponents.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:115115100.0 %
Date:2024-08-29 20:08:04Functions:44100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
count_connected_components97
test_cc_brutal1
test_cc_errors1
test_cc_matrices1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_ConnectedComponents.c.gcov.html b/src/test/test_ConnectedComponents.c.gcov.html new file mode 100644 index 0000000000..a0f2684b89 --- /dev/null +++ b/src/test/test_ConnectedComponents.c.gcov.html @@ -0,0 +1,351 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_ConnectedComponents.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_ConnectedComponents.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:115115100.0 %
Date:2024-08-29 20:08:04Functions:44100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph/src/test/test_ConnectedComponents.c: test cases for CC
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include <stdio.h>
+      19             : #include <acutest.h>
+      20             : 
+      21             : #include "LAGraph_test.h"
+      22             : // also test LG_CC_FastSV5 and LAGraph_cc_lacc
+      23             : #include "LAGraphX.h"
+      24             : #include "LG_alg_internal.h"
+      25             : 
+      26             : #undef NDEBUG
+      27             : #include <assert.h>
+      28             : 
+      29             : char msg [LAGRAPH_MSG_LEN] ;
+      30             : LAGraph_Graph G = NULL ;
+      31             : #define LEN 512
+      32             : char filename [LEN+1] ;
+      33             : GrB_Vector C = NULL, C2 = NULL ;
+      34             : GrB_Matrix A = NULL ;
+      35             : 
+      36             : typedef struct
+      37             : {
+      38             :     uint32_t ncomponents ;
+      39             :     const char *name ;
+      40             : }
+      41             : matrix_info ;
+      42             : 
+      43             : const matrix_info files [ ] =
+      44             : {
+      45             :     {      1, "karate.mtx" },
+      46             :     {      1, "A.mtx" },
+      47             :     {      1, "jagmesh7.mtx" },
+      48             :     {      1, "ldbc-cdlp-undirected-example.mtx" },
+      49             :     {      1, "ldbc-undirected-example.mtx" },
+      50             :     {      1, "ldbc-wcc-example.mtx" },
+      51             :     {      3, "LFAT5.mtx" },
+      52             :     {   1989, "LFAT5_hypersparse.mtx" },
+      53             :     {      6, "LFAT5_two.mtx" },
+      54             :     {      1, "bcsstk13.mtx" },
+      55             :     {      1, "tree-example.mtx" },
+      56             :     {   1391, "zenios.mtx" },
+      57             :     {      0, "" },
+      58             : } ;
+      59             : 
+      60             : //------------------------------------------------------------------------------
+      61             : // count_connected_components: count the # of components in a component vector
+      62             : //------------------------------------------------------------------------------
+      63             : 
+      64             : int count_connected_components (GrB_Vector C) ;
+      65             : 
+      66          97 : int count_connected_components (GrB_Vector C)
+      67             : {
+      68          97 :     GrB_Index n = 0 ;
+      69          97 :     OK (GrB_Vector_size (&n, C)) ;
+      70          97 :     int ncomponents = 0 ;
+      71       65165 :     for (int i = 0 ; i < n ; i++)
+      72             :     {
+      73       65068 :         int64_t comp = -1 ;
+      74       65068 :         int result = GrB_Vector_extractElement (&comp, C, i) ;
+      75       65068 :         if (result == GrB_SUCCESS && comp == i) ncomponents++ ;
+      76             :     }
+      77          97 :     return (ncomponents) ;
+      78             : }
+      79             : 
+      80             : //----------------------------------------------------------------------------
+      81             : // test_cc_matrices: test with several matrices
+      82             : //----------------------------------------------------------------------------
+      83             : 
+      84           1 : void test_cc_matrices (void)
+      85             : {
+      86             : 
+      87           1 :     OK (LAGraph_Init (msg)) ;
+      88             :     // OK (GxB_set (GxB_BURBLE, true)) ;
+      89             : 
+      90           1 :     for (int k = 0 ; ; k++)
+      91          12 :     {
+      92             : 
+      93             :         // load the adjacency matrix as A
+      94          13 :         const char *aname = files [k].name ;
+      95          13 :         uint32_t ncomp = files [k].ncomponents ;
+      96          13 :         if (strlen (aname) == 0) break;
+      97          12 :         printf ("\nMatrix: %s\n", aname) ;
+      98          12 :         TEST_CASE (aname) ;
+      99          12 :         snprintf (filename, LEN, LG_DATA_DIR "%s", aname) ;
+     100          12 :         FILE *f = fopen (filename, "r") ;
+     101          12 :         TEST_CHECK (f != NULL) ;
+     102          12 :         OK (LAGraph_MMRead (&A, f, msg)) ;
+     103          12 :         OK (fclose (f)) ;
+     104          12 :         TEST_MSG ("Loading of adjacency matrix failed") ;
+     105             :         GrB_Index n ;
+     106          12 :         OK (GrB_Matrix_nrows (&n, A)) ;
+     107             : 
+     108             :         // create the graph
+     109          12 :         OK (LAGraph_New (&G, &A, LAGraph_ADJACENCY_UNDIRECTED, msg)) ;
+     110          12 :         TEST_CHECK (A == NULL) ;    // A has been moved into G->A
+     111             : 
+     112          36 :         for (int trial = 0 ; trial <= 1 ; trial++)
+     113             :         {
+     114             :             // find the connected components
+     115          24 :             printf ("\n--- CC: FastSV6 if SuiteSparse, Boruvka if vanilla:\n") ;
+     116          24 :             OK (LAGr_ConnectedComponents (&C, G, msg)) ;
+     117          24 :             OK (LAGraph_Vector_Print (C, 2, stdout, msg)) ;
+     118             : 
+     119             :             // count the # of connected components
+     120          24 :             int ncomponents = count_connected_components (C) ;
+     121          24 :             printf ("# components: %6u Matrix: %s\n", ncomponents, aname) ;
+     122          24 :             TEST_CHECK (ncomponents == ncomp) ;
+     123             :             GrB_Index cnvals ;
+     124          24 :             OK (GrB_Vector_nvals (&cnvals, C)) ;
+     125          24 :             TEST_CHECK (cnvals == n) ;
+     126             : 
+     127             :             // check the result
+     128          24 :             OK (LG_check_cc (C, G, msg)) ;
+     129          24 :             OK (GrB_free (&C)) ;
+     130             : 
+     131             :             // find the connected components with LG_CC_FastSV5
+     132             :             #if LAGRAPH_SUITESPARSE
+     133          24 :             printf ("\n------ CC_FastSV5:\n") ;
+     134          24 :             OK (LG_CC_FastSV5 (&C2, G, msg)) ;
+     135          24 :             ncomponents = count_connected_components (C2) ;
+     136          24 :             TEST_CHECK (ncomponents == ncomp) ;
+     137          24 :             OK (LG_check_cc (C2, G, msg)) ;
+     138          24 :             OK (GrB_free (&C2)) ;
+     139             :             #endif
+     140             : 
+     141             :             // find the connected components with LG_CC_Boruvka
+     142          24 :             int result = GrB_SUCCESS ;
+     143          24 :             printf ("\n------ CC_BORUVKA:\n") ;
+     144          24 :             result = LG_CC_Boruvka (&C2, G, msg) ;
+     145          24 :             OK (result) ;
+     146          24 :             ncomponents = count_connected_components (C2) ;
+     147          24 :             TEST_CHECK (ncomponents == ncomp) ;
+     148          24 :             OK (LG_check_cc (C2, G, msg)) ;
+     149          24 :             OK (GrB_free (&C2)) ;
+     150             : 
+     151          24 :             result = LG_CC_Boruvka (NULL, G, msg) ;
+     152          24 :             TEST_CHECK (result == GrB_NULL_POINTER) ;
+     153             : 
+     154          24 :             if (trial == 0)
+     155             :             {
+     156          36 :                 for (int sanitize = 0 ; sanitize <= 1 ; sanitize++)
+     157             :                 {
+     158             :                     // find the connected components with cc_lacc
+     159          24 :                     printf ("\n------ CC_LACC:\n") ;
+     160          24 :                     OK (LAGraph_cc_lacc (&C2, G->A, sanitize, msg)) ;
+     161          24 :                     ncomponents = count_connected_components (C2) ;
+     162          24 :                     TEST_CHECK (ncomponents == ncomp) ;
+     163          24 :                     OK (LG_check_cc (C2, G, msg)) ;
+     164          24 :                     OK (GrB_free (&C2)) ;
+     165             :                 }
+     166             : 
+     167          12 :                 result = LAGraph_cc_lacc (NULL, G->A, false, msg) ;
+     168          12 :                 TEST_CHECK (result == GrB_NULL_POINTER) ;
+     169             :             }
+     170             : 
+     171             :             // convert to directed with symmetric pattern for next trial
+     172          24 :             G->kind = LAGraph_ADJACENCY_DIRECTED ;
+     173          24 :             G->is_symmetric_structure = LAGraph_TRUE ;
+     174             :         }
+     175             : 
+     176          12 :         OK (LAGraph_Delete (&G, msg)) ;
+     177             :     }
+     178             : 
+     179           1 :     OK (LAGraph_Finalize (msg)) ;
+     180           1 : }
+     181             : 
+     182             : //------------------------------------------------------------------------------
+     183             : // test_CC_errors:
+     184             : //------------------------------------------------------------------------------
+     185             : 
+     186           1 : void test_cc_errors (void)
+     187             : {
+     188           1 :     OK (LAGraph_Init (msg)) ;
+     189           1 :     printf ("\n") ;
+     190             : 
+     191             :     // check for null pointers
+     192           1 :     int result = GrB_SUCCESS ;
+     193             : 
+     194           1 :     result = LG_CC_Boruvka (NULL, NULL, msg) ;
+     195           1 :     TEST_CHECK (result == GrB_NULL_POINTER) ;
+     196             : 
+     197             :     #if LAGRAPH_SUITESPARSE
+     198           1 :     result = LG_CC_FastSV6 (NULL, NULL, msg) ;
+     199           1 :     TEST_CHECK (result == GrB_NULL_POINTER) ;
+     200             :     #endif
+     201             : 
+     202             :     // load a valid matrix
+     203           1 :     FILE *f = fopen (LG_DATA_DIR "LFAT5_two.mtx", "r") ;
+     204           1 :     TEST_CHECK (f != NULL) ;
+     205           1 :     OK (LAGraph_MMRead (&A, f, msg)) ;
+     206           1 :     OK (fclose (f)) ;
+     207             : 
+     208             :     // create an valid directed graph (not known to be symmetric)
+     209           1 :     OK (LAGraph_New (&G, &A, LAGraph_ADJACENCY_DIRECTED, msg)) ;
+     210           1 :     TEST_CHECK (A == NULL) ;    // A has been moved into G->A
+     211             : 
+     212           1 :     result = LG_CC_Boruvka (&C, G, msg) ;
+     213           1 :     TEST_CHECK (result == -1001) ;
+     214           1 :     printf ("result expected: %d msg:\n%s\n", result, msg) ;
+     215             : 
+     216             :     #if LAGRAPH_SUITESPARSE
+     217           1 :     result = LG_CC_FastSV6 (&C, G, msg) ;
+     218           1 :     TEST_CHECK (result == -1001) ;
+     219           1 :     printf ("result expected: %d msg:\n%s\n", result, msg) ;
+     220             :     #endif
+     221             : 
+     222           1 :     OK (LAGraph_Finalize (msg)) ;
+     223           1 : }
+     224             : 
+     225             : //------------------------------------------------------------------------------
+     226             : // test_CC_brutal:
+     227             : //------------------------------------------------------------------------------
+     228             : 
+     229             : #if LAGRAPH_SUITESPARSE
+     230           1 : void test_cc_brutal (void)
+     231             : {
+     232           1 :     OK (LG_brutal_setup (msg)) ;
+     233             : 
+     234             :     // load a valid adjacency matrix
+     235           1 :     TEST_CASE ("LFAT5_two") ;
+     236           1 :     uint32_t ncomp = 6 ;
+     237           1 :     FILE *f = fopen (LG_DATA_DIR "LFAT5_two.mtx", "r") ;
+     238           1 :     TEST_CHECK (f != NULL) ;
+     239           1 :     OK (LAGraph_MMRead (&A, f, msg)) ;
+     240           1 :     OK (fclose (f)) ;
+     241           1 :     TEST_MSG ("Loading of LFAT5_two.mtx failed") ;
+     242           1 :     printf ("\n") ;
+     243             : 
+     244             :     // create an valid graph
+     245           1 :     OK (LAGraph_New (&G, &A, LAGraph_ADJACENCY_UNDIRECTED, msg)) ;
+     246           1 :     TEST_CHECK (A == NULL) ;    // A has been moved into G->A
+     247           1 :     LG_BRUTAL_BURBLE (LAGraph_CheckGraph (G, msg)) ;
+     248             : 
+     249             :     // find the connected components
+     250           1 :     printf ("\n--- CC: FastSV6 if SuiteSparse, Boruvka if vanilla:\n") ;
+     251          38 :     LG_BRUTAL_BURBLE (LAGr_ConnectedComponents (&C, G, msg)) ;
+     252           3 :     LG_BRUTAL_BURBLE (LAGraph_Vector_Print (C, LAGraph_SHORT, stdout, msg)) ;
+     253             : 
+     254             :     // count the # of connected components
+     255           1 :     int ncomponents = count_connected_components (C) ;
+     256           1 :     printf ("# components: %6u Matrix: %s\n", ncomponents, "LFAT_two") ;
+     257           1 :     TEST_CHECK (ncomponents == ncomp) ;
+     258           1 :     OK (LG_check_cc (C, G, msg)) ;
+     259             : 
+     260           1 :     OK (LAGraph_Delete (&G, msg)) ;
+     261           1 :     OK (GrB_free (&C)) ;
+     262           1 :     OK (LG_brutal_teardown (msg)) ;
+     263           1 : }
+     264             : #endif
+     265             : 
+     266             : //****************************************************************************
+     267             : //****************************************************************************
+     268             : TEST_LIST = {
+     269             :     {"cc", test_cc_matrices},
+     270             :     #if LAGRAPH_SUITESPARSE
+     271             :     {"cc_brutal", test_cc_brutal},
+     272             :     #endif
+     273             :     {"cc_errors", test_cc_errors},
+     274             :     {NULL, NULL}
+     275             : };
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_DeleteCached.c.func-sort-c.html b/src/test/test_DeleteCached.c.func-sort-c.html new file mode 100644 index 0000000000..4224d90af2 --- /dev/null +++ b/src/test/test_DeleteCached.c.func-sort-c.html @@ -0,0 +1,88 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_DeleteCached.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_DeleteCached.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:8282100.0 %
Date:2024-08-29 20:08:04Functions:44100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
setup1
teardown1
test_DeleteCached1
test_del_brutal1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_DeleteCached.c.func.html b/src/test/test_DeleteCached.c.func.html new file mode 100644 index 0000000000..368f27e551 --- /dev/null +++ b/src/test/test_DeleteCached.c.func.html @@ -0,0 +1,88 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_DeleteCached.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_DeleteCached.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:8282100.0 %
Date:2024-08-29 20:08:04Functions:44100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
setup1
teardown1
test_DeleteCached1
test_del_brutal1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_DeleteCached.c.gcov.html b/src/test/test_DeleteCached.c.gcov.html new file mode 100644 index 0000000000..d469b533ce --- /dev/null +++ b/src/test/test_DeleteCached.c.gcov.html @@ -0,0 +1,277 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_DeleteCached.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_DeleteCached.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:8282100.0 %
Date:2024-08-29 20:08:04Functions:44100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph/src/test/test_DeleteCached.c:  test LAGraph_DeleteCached
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include "LAGraph_test.h"
+      19             : 
+      20             : //------------------------------------------------------------------------------
+      21             : // global variables
+      22             : //------------------------------------------------------------------------------
+      23             : 
+      24             : LAGraph_Graph G = NULL ;
+      25             : char msg [LAGRAPH_MSG_LEN] ;
+      26             : GrB_Matrix A = NULL ;
+      27             : #define LEN 512
+      28             : char filename [LEN+1] ;
+      29             : 
+      30             : //------------------------------------------------------------------------------
+      31             : // setup: start a test
+      32             : //------------------------------------------------------------------------------
+      33             : 
+      34           1 : void setup (void)
+      35             : {
+      36           1 :     OK (LAGraph_Init (msg)) ;
+      37           1 : }
+      38             : 
+      39             : //------------------------------------------------------------------------------
+      40             : // teardown: finalize a test
+      41             : //------------------------------------------------------------------------------
+      42             : 
+      43           1 : void teardown (void)
+      44             : {
+      45           1 :     OK (LAGraph_Finalize (msg)) ;
+      46           1 : }
+      47             : 
+      48             : //------------------------------------------------------------------------------
+      49             : // test_DeleteCached:  test LAGraph_DeleteCached
+      50             : //------------------------------------------------------------------------------
+      51             : 
+      52             : typedef struct
+      53             : {
+      54             :     LAGraph_Kind kind ;
+      55             :     const char *name ;
+      56             : }
+      57             : matrix_info ;
+      58             : 
+      59             : const matrix_info files [ ] =
+      60             : {
+      61             :     LAGraph_ADJACENCY_DIRECTED,   "cover.mtx",
+      62             :     LAGraph_ADJACENCY_DIRECTED,   "ldbc-directed-example.mtx",
+      63             :     LAGraph_ADJACENCY_UNDIRECTED, "ldbc-undirected-example.mtx",
+      64             :     LAGraph_ADJACENCY_UNDIRECTED, "A.mtx",
+      65             :     LAGraph_ADJACENCY_UNDIRECTED, "bcsstk13.mtx",
+      66             :     LAGRAPH_UNKNOWN,              ""
+      67             : } ;
+      68             : 
+      69           1 : void test_DeleteCached (void)
+      70             : {
+      71           1 :     setup ( ) ;
+      72             : 
+      73           1 :     for (int k = 0 ; ; k++)
+      74           5 :     {
+      75             : 
+      76             :         // load the matrix as A
+      77           6 :         const char *aname = files [k].name ;
+      78           6 :         if (strlen (aname) == 0) break;
+      79           5 :         LAGraph_Kind kind = files [k].kind ;
+      80           5 :         TEST_CASE (aname) ;
+      81           5 :         snprintf (filename, LEN, LG_DATA_DIR "%s", aname) ;
+      82           5 :         FILE *f = fopen (filename, "r") ;
+      83           5 :         TEST_CHECK (f != NULL) ;
+      84           5 :         OK (LAGraph_MMRead (&A, f, msg)) ;
+      85           5 :         OK (fclose (f)) ;
+      86           5 :         TEST_MSG ("Loading of adjacency matrix failed") ;
+      87             : 
+      88             :         // construct the graph G with adjacency matrix A
+      89           5 :         OK (LAGraph_New (&G, &A, kind, msg)) ;
+      90           5 :         TEST_CHECK (A == NULL) ;
+      91             : 
+      92             :         // create all cached properties (see test_Cached_* for tests of content)
+      93           5 :         int ok_result = (kind == LAGraph_ADJACENCY_UNDIRECTED) ?
+      94           5 :             LAGRAPH_CACHE_NOT_NEEDED : GrB_SUCCESS ;
+      95           5 :         OK (LAGraph_Cached_OutDegree (G, msg)) ;
+      96           5 :         int result = LAGraph_Cached_InDegree (G, msg) ;
+      97           5 :         TEST_CHECK (result == ok_result) ;
+      98           5 :         result = LAGraph_Cached_AT (G, msg) ;
+      99           5 :         TEST_CHECK (result == ok_result) ;
+     100           5 :         OK (LAGraph_Cached_IsSymmetricStructure (G, msg)) ;
+     101             : 
+     102             :         // print them
+     103           5 :         printf ("\nGraph: nself_edges %g, symmetric structure: %d\n",
+     104           5 :             (double) G->nself_edges, G->is_symmetric_structure) ;
+     105           5 :         printf ("  adj matrix: ") ;
+     106           5 :         int rr = (LAGraph_Matrix_Print (G->A, LAGraph_SHORT, stdout, msg)) ;
+     107           5 :         printf ("result: %d msg: %s\n", rr, msg) ;
+     108           5 :         printf ("  out degree: ") ;
+     109           5 :         OK (LAGraph_Vector_Print (G->out_degree, LAGraph_SHORT, stdout, msg)) ;
+     110           5 :         if (kind == LAGraph_ADJACENCY_DIRECTED)
+     111             :         {
+     112           2 :             printf ("  adj transposed: ") ;
+     113           2 :             OK (LAGraph_Matrix_Print (G->AT, LAGraph_SHORT, stdout, msg)) ;
+     114           2 :             printf ("  in degree: ") ;
+     115           2 :             OK (LAGraph_Vector_Print (G->in_degree, LAGraph_SHORT, stdout,
+     116             :                 msg)) ;
+     117             :         }
+     118             :         else
+     119             :         {
+     120           3 :             TEST_CHECK (G->AT == NULL) ;
+     121           3 :             TEST_CHECK (G->in_degree == NULL) ;
+     122             :         }
+     123             : 
+     124          15 :         for (int trial = 0 ; trial <= 1 ; trial++)
+     125             :         {
+     126             :             // delete all the cached properties
+     127          10 :             OK (LAGraph_DeleteCached (G, msg)) ;
+     128          10 :             TEST_CHECK (G->AT == NULL) ;
+     129          10 :             TEST_CHECK (G->out_degree == NULL) ;
+     130          10 :             TEST_CHECK (G->in_degree == NULL) ;
+     131             :         }
+     132             : 
+     133           5 :         OK (LAGraph_Delete (&G, msg)) ;
+     134             :     }
+     135             : 
+     136           1 :     OK (LAGraph_DeleteCached (NULL, msg)) ;
+     137             : 
+     138           1 :     teardown ( ) ;
+     139           1 : }
+     140             : 
+     141             : //-----------------------------------------------------------------------------
+     142             : 
+     143             : #if LAGRAPH_SUITESPARSE
+     144           1 : void test_del_brutal (void)
+     145             : {
+     146           1 :     OK (LG_brutal_setup (msg)) ;
+     147             : 
+     148           1 :     for (int k = 0 ; ; k++)
+     149           5 :     {
+     150             : 
+     151             :         // load the matrix as A
+     152           6 :         const char *aname = files [k].name ;
+     153           6 :         if (strlen (aname) == 0) break;
+     154           5 :         LAGraph_Kind kind = files [k].kind ;
+     155           5 :         TEST_CASE (aname) ;
+     156           5 :         snprintf (filename, LEN, LG_DATA_DIR "%s", aname) ;
+     157           5 :         FILE *f = fopen (filename, "r") ;
+     158           5 :         TEST_CHECK (f != NULL) ;
+     159           5 :         OK (LAGraph_MMRead (&A, f, msg)) ;
+     160           5 :         OK (fclose (f)) ;
+     161           5 :         TEST_MSG ("Loading of adjacency matrix failed") ;
+     162             : 
+     163             :         // construct the graph G with adjacency matrix A
+     164          10 :         LG_BRUTAL (LAGraph_New (&G, &A, kind, msg)) ;
+     165           5 :         TEST_CHECK (A == NULL) ;
+     166             : 
+     167             :         // create all cached properties (see test_Cached_* for tests of content)
+     168          39 :         LG_BRUTAL (LAGraph_Cached_OutDegree (G, msg)) ;
+     169          19 :         LG_BRUTAL (LAGraph_Cached_InDegree (G, msg)) ;
+     170          15 :         LG_BRUTAL (LAGraph_Cached_AT (G, msg)) ;
+     171          17 :         LG_BRUTAL (LAGraph_Cached_IsSymmetricStructure (G, msg)) ;
+     172             : 
+     173          15 :         for (int trial = 0 ; trial <= 1 ; trial++)
+     174             :         {
+     175             :             // delete all the cached properties
+     176          10 :             LG_BRUTAL (LAGraph_DeleteCached (G, msg)) ;
+     177          10 :             TEST_CHECK (G->AT == NULL) ;
+     178          10 :             TEST_CHECK (G->out_degree == NULL) ;
+     179          10 :             TEST_CHECK (G->in_degree == NULL) ;
+     180             :         }
+     181             : 
+     182           5 :         LG_BRUTAL (LAGraph_Delete (&G, msg)) ;
+     183           5 :         LG_BRUTAL (LAGraph_DeleteCached (NULL, msg)) ;
+     184             :     }
+     185             : 
+     186           1 :     OK (LG_brutal_teardown (msg)) ;
+     187           1 : }
+     188             : #endif
+     189             : 
+     190             : //-----------------------------------------------------------------------------
+     191             : // TEST_LIST: the list of tasks for this entire test
+     192             : //-----------------------------------------------------------------------------
+     193             : 
+     194             : TEST_LIST =
+     195             : {
+     196             :     { "test_DeleteCached", test_DeleteCached },
+     197             :     #if LAGRAPH_SUITESPARSE
+     198             :     { "test_DeleteCached_brutal", test_del_brutal },
+     199             :     #endif
+     200             :     { NULL, NULL }
+     201             : } ;
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_DisplayGraph.c.func-sort-c.html b/src/test/test_DisplayGraph.c.func-sort-c.html new file mode 100644 index 0000000000..dc338db967 --- /dev/null +++ b/src/test/test_DisplayGraph.c.func-sort-c.html @@ -0,0 +1,96 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_DisplayGraph.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_DisplayGraph.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:132132100.0 %
Date:2024-08-29 20:08:04Functions:66100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_Graph_Print1
test_Graph_Print_brutal1
test_Graph_Print_failures1
setup2
teardown2
prwhat97
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_DisplayGraph.c.func.html b/src/test/test_DisplayGraph.c.func.html new file mode 100644 index 0000000000..bdb04e5104 --- /dev/null +++ b/src/test/test_DisplayGraph.c.func.html @@ -0,0 +1,96 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_DisplayGraph.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_DisplayGraph.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:132132100.0 %
Date:2024-08-29 20:08:04Functions:66100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
prwhat97
setup2
teardown2
test_Graph_Print1
test_Graph_Print_brutal1
test_Graph_Print_failures1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_DisplayGraph.c.gcov.html b/src/test/test_DisplayGraph.c.gcov.html new file mode 100644 index 0000000000..7d09dd8cff --- /dev/null +++ b/src/test/test_DisplayGraph.c.gcov.html @@ -0,0 +1,378 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_DisplayGraph.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_DisplayGraph.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:132132100.0 %
Date:2024-08-29 20:08:04Functions:66100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph/src/test/test_Graph_Print.c:  test LAGraph_Graph_Print
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include "LAGraph_test.h"
+      19             : #include "LG_internal.h"
+      20             : 
+      21             : //------------------------------------------------------------------------------
+      22             : // global variables
+      23             : //------------------------------------------------------------------------------
+      24             : 
+      25             : LAGraph_Graph G = NULL ;
+      26             : char msg [LAGRAPH_MSG_LEN] ;
+      27             : GrB_Matrix A = NULL, AT = NULL ;
+      28             : #define LEN 512
+      29             : char filename [LEN+1] ;
+      30             : char atype_name [LAGRAPH_MAX_NAME_LEN] ;
+      31             : 
+      32             : //------------------------------------------------------------------------------
+      33             : // setup: start a test
+      34             : //------------------------------------------------------------------------------
+      35             : 
+      36           2 : void setup (void)
+      37             : {
+      38           2 :     OK (LAGraph_Init (msg)) ;
+      39           2 : }
+      40             : 
+      41             : //------------------------------------------------------------------------------
+      42             : // teardown: finalize a test
+      43             : //------------------------------------------------------------------------------
+      44             : 
+      45           2 : void teardown (void)
+      46             : {
+      47           2 :     OK (LAGraph_Finalize (msg)) ;
+      48           2 : }
+      49             : 
+      50             : //------------------------------------------------------------------------------
+      51             : // prwhat: print what should be printed
+      52             : //------------------------------------------------------------------------------
+      53             : 
+      54          97 : const char *prwhat (int pr)
+      55             : {
+      56          97 :     switch (pr)
+      57             :     {
+      58          16 :         case  0: return ("nothing") ;
+      59          16 :         case  1: return ("terse") ;
+      60          16 :         case  2: return ("summary") ;
+      61          16 :         case  3: return ("all") ;
+      62          16 :         case  4: return ("summary (doubles in full precision)") ;
+      63          16 :         case  5: return ("all (doubles in full precision)") ;
+      64           1 :         default: ;
+      65             :     }
+      66           1 :     return (NULL) ;
+      67             : }
+      68             : 
+      69             : //------------------------------------------------------------------------------
+      70             : // test_Graph_Print:  test LAGraph_Graph_Print
+      71             : //------------------------------------------------------------------------------
+      72             : 
+      73             : typedef struct
+      74             : {
+      75             :     LAGraph_Kind kind ;
+      76             :     int nself_edges ;
+      77             :     const char *name ;
+      78             : }
+      79             : matrix_info ;
+      80             : 
+      81             : const matrix_info files [ ] =
+      82             : {
+      83             :     LAGraph_ADJACENCY_DIRECTED,   0, "cover.mtx",
+      84             :     LAGraph_ADJACENCY_DIRECTED,   0, "ldbc-directed-example.mtx",
+      85             :     LAGraph_ADJACENCY_UNDIRECTED, 0, "ldbc-undirected-example.mtx",
+      86             :     LAGraph_ADJACENCY_DIRECTED,   2, "west0067.mtx",
+      87             :     LAGRAPH_UNKNOWN,              0, ""
+      88             : } ;
+      89             : 
+      90           1 : void test_Graph_Print (void)
+      91             : {
+      92           1 :     setup ( ) ;
+      93             : 
+      94           1 :     for (int k = 0 ; ; k++)
+      95           4 :     {
+      96             : 
+      97             :         // load the adjacency matrix as A
+      98           5 :         const char *aname = files [k].name ;
+      99           5 :         LAGraph_Kind kind = files [k].kind ;
+     100           5 :         if (strlen (aname) == 0) break;
+     101           4 :         TEST_CASE (aname) ;
+     102           4 :         snprintf (filename, LEN, LG_DATA_DIR "%s", aname) ;
+     103           4 :         FILE *f = fopen (filename, "r") ;
+     104           4 :         TEST_CHECK (f != NULL) ;
+     105           4 :         OK (LAGraph_MMRead (&A, f, msg)) ;
+     106           4 :         OK (fclose (f)) ;
+     107           4 :         TEST_MSG ("Loading of adjacency matrix failed") ;
+     108             : 
+     109           4 :         OK (LAGraph_Matrix_TypeName (atype_name, A, msg)) ;
+     110           4 :         if (MATCHNAME (atype_name, "double"))
+     111             :         {
+     112           3 :             OK (GrB_Matrix_setElement (A, 3.14159265358979323, 0, 1)) ;
+     113             :         }
+     114             : 
+     115             :         // create the graph
+     116           4 :         OK (LAGraph_New (&G, &A, kind, msg)) ;
+     117           4 :         TEST_CHECK (A == NULL) ;    // A has been moved into G->A
+     118             : 
+     119             :         // display the graph
+     120          12 :         for (int trial = 0 ; trial <= 1 ; trial++)
+     121             :         {
+     122           8 :             printf ("\n############################# TRIAL: %d\n", trial) ;
+     123          56 :             for (int pr = 0 ; pr <= 5 ; pr++)
+     124             :             {
+     125          48 :                 printf ("\n########### %s: pr: %d (%s)\n",
+     126             :                     aname, pr, prwhat (pr)) ;
+     127          48 :                 LAGraph_PrintLevel prl = pr ;
+     128          48 :                 OK (LAGraph_Graph_Print (G, prl, stdout, msg)) ;
+     129             :             }
+     130           8 :             int ok_result = (kind == LAGraph_ADJACENCY_UNDIRECTED) ?
+     131           8 :                 LAGRAPH_CACHE_NOT_NEEDED : GrB_SUCCESS ;
+     132           8 :             int result = LAGraph_Cached_AT (G, msg) ;
+     133           8 :             TEST_CHECK (result == ok_result) ;
+     134           8 :             OK (LAGraph_Cached_IsSymmetricStructure (G, msg)) ;
+     135           8 :             OK (LAGraph_Cached_NSelfEdges (G, msg)) ;
+     136           8 :             TEST_CHECK (G->nself_edges == files [k].nself_edges) ;
+     137             :         }
+     138             : 
+     139             :         // free the graph
+     140           4 :         OK (LAGraph_Delete (&G, msg)) ;
+     141           4 :         TEST_CHECK (G == NULL) ;
+     142             :     }
+     143             : 
+     144           1 :     TEST_CHECK (prwhat (999) == NULL) ;
+     145           1 :     teardown ( ) ;
+     146           1 : }
+     147             : 
+     148             : //------------------------------------------------------------------------------
+     149             : // test_Graph_Print_failures:  test error handling of LAGraph_Graph_Print
+     150             : //------------------------------------------------------------------------------
+     151             : 
+     152           1 : void test_Graph_Print_failures (void)
+     153             : {
+     154           1 :     setup ( ) ;
+     155             : 
+     156             :     // G cannot be NULL
+     157           1 :     int result = LAGraph_New (NULL, NULL, 0, msg) ;
+     158           1 :     printf ("\nresult: %d, msg: %s\n", result, msg) ;
+     159           1 :     TEST_CHECK (result == GrB_NULL_POINTER) ;
+     160             : 
+     161             :     // create a graph with no adjacency matrix; this is OK, since the intent is
+     162             :     // to create a graph for which the adjacency matrix can be defined later,
+     163             :     // via assigning it to G->A.  However, the graph will be declared invalid
+     164             :     // by LAGraph_CheckGraph since G->A is NULL.
+     165           1 :     OK (LAGraph_New (&G, NULL, LAGraph_ADJACENCY_UNDIRECTED, msg)) ;
+     166             : 
+     167             :     // G->A is NULL
+     168           1 :     LAGraph_PrintLevel pr = LAGraph_COMPLETE_VERBOSE ;
+     169           1 :     result = LAGraph_Graph_Print (G, pr, stdout, msg) ;
+     170           1 :     printf ("result: %d, msg: %s\n", result, msg) ;
+     171           1 :     TEST_CHECK (result == LAGRAPH_INVALID_GRAPH) ;
+     172             : 
+     173           1 :     OK (LAGraph_Delete (&G, msg)) ;
+     174           1 :     TEST_CHECK (G == NULL) ;
+     175             : 
+     176             :     // valid graph
+     177           1 :     OK (GrB_Matrix_new (&A, GrB_FP32, 5, 5)) ;
+     178           1 :     OK (LAGraph_New (&G, &A, LAGraph_ADJACENCY_UNDIRECTED, msg)) ;
+     179           1 :     result = LAGraph_Graph_Print (G, pr, stdout, msg) ;
+     180           1 :     printf ("result: %d, msg: %s\n", result, msg) ;
+     181           1 :     TEST_CHECK (result == GrB_SUCCESS) ;
+     182             : 
+     183             :     // mangled G->kind
+     184           1 :     G->kind = -1 ;
+     185           1 :     result = LAGraph_Graph_Print (G, pr, stdout, msg) ;
+     186           1 :     printf ("result: %d, msg: %s\n", result, msg) ;
+     187           1 :     TEST_CHECK (result == LAGRAPH_INVALID_GRAPH) ;
+     188           1 :     G->kind = LAGraph_ADJACENCY_UNDIRECTED ;
+     189             : 
+     190             :     // G->AT has the wrong size
+     191           1 :     OK (GrB_Matrix_new (&(G->AT), GrB_FP32, 6, 5)) ;
+     192           1 :     result = LAGraph_Graph_Print (G, pr, stdout, msg) ;
+     193           1 :     printf ("result: %d, msg: %s\n", result, msg) ;
+     194           1 :     TEST_CHECK (result == LAGRAPH_INVALID_GRAPH) ;
+     195             : 
+     196           1 :     OK (GrB_free (&G->AT)) ;
+     197           1 :     OK (GrB_Matrix_new (&(G->AT), GrB_FP32, 5, 5)) ;
+     198             : 
+     199             :     #if LAGRAPH_SUITESPARSE
+     200             :     // G->AT must be held by row, not by column
+     201           1 :     OK (GxB_set (G->AT, GxB_FORMAT, GxB_BY_COL)) ;
+     202           1 :     result = LAGraph_Graph_Print (G, pr, stdout, msg) ;
+     203           1 :     printf ("result: %d, msg: %s\n", result, msg) ;
+     204           1 :     TEST_CHECK (result == LAGRAPH_INVALID_GRAPH) ;
+     205             :     #endif
+     206             : 
+     207             :     // G->A and G->AT must have the same types
+     208           1 :     OK (GrB_free (&G->AT)) ;
+     209           1 :     OK (GrB_Matrix_new (&(G->AT), GrB_FP64, 5, 5)) ;
+     210           1 :     result = LAGraph_Graph_Print (G, pr, stdout, msg) ;
+     211           1 :     printf ("result: %d, msg: %s\n", result, msg) ;
+     212           1 :     TEST_CHECK (result == LAGRAPH_INVALID_GRAPH) ;
+     213             : 
+     214           1 :     OK (LAGraph_Delete (&G, msg)) ;
+     215           1 :     TEST_CHECK (G == NULL) ;
+     216             : 
+     217           1 :     OK (LAGraph_Delete (NULL, msg)) ;
+     218           1 :     teardown ( ) ;
+     219           1 : }
+     220             : 
+     221             : //-----------------------------------------------------------------------------
+     222             : // test_Graph_Print_brutal
+     223             : //-----------------------------------------------------------------------------
+     224             : 
+     225             : #if LAGRAPH_SUITESPARSE
+     226           1 : void test_Graph_Print_brutal (void)
+     227             : {
+     228           1 :     OK (LG_brutal_setup (msg)) ;
+     229             : 
+     230           1 :     for (int k = 0 ; ; k++)
+     231           4 :     {
+     232             : 
+     233             :         // load the adjacency matrix as A
+     234           5 :         const char *aname = files [k].name ;
+     235           5 :         LAGraph_Kind kind = files [k].kind ;
+     236           5 :         if (strlen (aname) == 0) break;
+     237           4 :         TEST_CASE (aname) ;
+     238           4 :         snprintf (filename, LEN, LG_DATA_DIR "%s", aname) ;
+     239           4 :         FILE *f = fopen (filename, "r") ;
+     240           4 :         TEST_CHECK (f != NULL) ;
+     241           4 :         OK (LAGraph_MMRead (&A, f, msg)) ;
+     242           4 :         OK (fclose (f)) ;
+     243           4 :         TEST_MSG ("Loading of adjacency matrix failed") ;
+     244             : 
+     245           4 :         OK (LAGraph_Matrix_TypeName (atype_name, A, msg)) ;
+     246           4 :         if (MATCHNAME (atype_name, "double"))
+     247             :         {
+     248           3 :             OK (GrB_Matrix_setElement (A, 3.14159265358979323, 0, 1)) ;
+     249             :         }
+     250           4 :         OK (GrB_wait (A, GrB_MATERIALIZE)) ;
+     251             : 
+     252             :         // create the graph
+     253           4 :         OK (LAGraph_New (&G, &A, kind, msg)) ;
+     254           4 :         OK (LAGraph_CheckGraph (G, msg)) ;
+     255             : 
+     256             :         // display the graph
+     257          12 :         for (int trial = 0 ; trial <= 1 ; trial++)
+     258             :         {
+     259           8 :             printf ("\n############################# TRIAL: %d\n", trial) ;
+     260          56 :             for (int pr = 0 ; pr <= 5 ; pr++)
+     261             :             {
+     262          48 :                 printf ("\n########### %s: pr: %d (%s)\n",
+     263             :                     aname, pr, prwhat (pr)) ;
+     264          48 :                 LAGraph_PrintLevel prl = pr ;
+     265          48 :                 if (pr == 3 || pr == 5)
+     266             :                 {
+     267          16 :                     printf ("skipped for brutal tests\n") ;
+     268             :                 }
+     269             :                 else
+     270             :                 {
+     271         114 :                     LG_BRUTAL (LAGraph_Graph_Print (G, prl, stdout, msg)) ;
+     272             :                 }
+     273             :             }
+     274           8 :             int ok_result = (kind == LAGraph_ADJACENCY_UNDIRECTED) ?
+     275           8 :                 LAGRAPH_CACHE_NOT_NEEDED : GrB_SUCCESS ;
+     276           8 :             int result = LAGraph_Cached_AT (G, msg) ;
+     277           8 :             TEST_CHECK (result == ok_result) ;
+     278           8 :             OK (LAGraph_Cached_IsSymmetricStructure (G, msg)) ;
+     279           8 :             OK (LAGraph_Cached_NSelfEdges (G, msg)) ;
+     280             :         }
+     281             : 
+     282             :         // free the graph
+     283           4 :         OK (LAGraph_Delete (&G, msg)) ;
+     284             :     }
+     285             : 
+     286           1 :     OK (LG_brutal_teardown (msg)) ;
+     287           1 : }
+     288             : #endif
+     289             : 
+     290             : //-----------------------------------------------------------------------------
+     291             : // TEST_LIST: the list of tasks for this entire test
+     292             : //-----------------------------------------------------------------------------
+     293             : 
+     294             : TEST_LIST =
+     295             : {
+     296             :     { "Graph_Print", test_Graph_Print },
+     297             :     #if LAGRAPH_SUITESPARSE
+     298             :     { "Graph_Print_brutal", test_Graph_Print_brutal },
+     299             :     #endif
+     300             :     { "Graph_Print_failures", test_Graph_Print_failures },
+     301             :     { NULL, NULL }
+     302             : } ;
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_Init.c.func-sort-c.html b/src/test/test_Init.c.func-sort-c.html new file mode 100644 index 0000000000..dba1473dd8 --- /dev/null +++ b/src/test/test_Init.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_Init.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_Init.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:2525100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_Init1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_Init.c.func.html b/src/test/test_Init.c.func.html new file mode 100644 index 0000000000..ae13dfd730 --- /dev/null +++ b/src/test/test_Init.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_Init.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_Init.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:2525100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_Init1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_Init.c.gcov.html b/src/test/test_Init.c.gcov.html new file mode 100644 index 0000000000..ad4a52e826 --- /dev/null +++ b/src/test/test_Init.c.gcov.html @@ -0,0 +1,172 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_Init.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_Init.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:2525100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph/src/test/test_Init.c:  test LAGraph_Init and LAGraph_Finalize
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include "LAGraph_test.h"
+      19             : 
+      20             : //------------------------------------------------------------------------------
+      21             : // global variables
+      22             : //------------------------------------------------------------------------------
+      23             : 
+      24             : char msg [LAGRAPH_MSG_LEN] ;
+      25             : 
+      26             : //------------------------------------------------------------------------------
+      27             : // test_Init:  test LAGraph_Init
+      28             : //------------------------------------------------------------------------------
+      29             : 
+      30           1 : void test_Init (void)
+      31             : {
+      32             : 
+      33           1 :     int status = LAGraph_Init (msg) ;
+      34           1 :     OK (status) ;
+      35             :     int ver [3] ;
+      36             : 
+      37             :     #if LAGRAPH_SUITESPARSE
+      38             :     const char *name, *date ;
+      39           1 :     OK (GxB_Global_Option_get (GxB_LIBRARY_NAME, &name)) ;
+      40           1 :     OK (GxB_Global_Option_get (GxB_LIBRARY_DATE, &date)) ;
+      41           1 :     OK (GxB_Global_Option_get (GxB_LIBRARY_VERSION, ver)) ;
+      42           1 :     printf ("\nlibrary: %s %d.%d.%d (%s)\n", name, ver [0], ver [1], ver [2],
+      43             :         date) ;
+      44           1 :     printf (  "include: %s %d.%d.%d (%s)\n", GxB_IMPLEMENTATION_NAME,
+      45             :         GxB_IMPLEMENTATION_MAJOR, GxB_IMPLEMENTATION_MINOR,
+      46             :         GxB_IMPLEMENTATION_SUB, GxB_IMPLEMENTATION_DATE) ;
+      47             :     // make sure the SuiteSparse:GraphBLAS version and date match
+      48           1 :     TEST_CHECK (ver [0] == GxB_IMPLEMENTATION_MAJOR) ;
+      49           1 :     TEST_CHECK (ver [1] == GxB_IMPLEMENTATION_MINOR) ;
+      50           1 :     TEST_CHECK (ver [2] == GxB_IMPLEMENTATION_SUB) ;
+      51           1 :     OK (strcmp (date, GxB_IMPLEMENTATION_DATE)) ;
+      52             : 
+      53             :     #if ( GxB_IMPLEMENTATION_MAJOR >= 7 )
+      54             :     char *compiler ;
+      55             :     int compiler_version [3] ;
+      56           1 :     OK (GxB_Global_Option_get (GxB_COMPILER_NAME, &compiler)) ;
+      57           1 :     OK (GxB_Global_Option_get (GxB_COMPILER_VERSION, compiler_version)) ;
+      58           1 :     printf ("GraphBLAS compiled with: %s v%d.%d.%d\n", compiler,
+      59             :         compiler_version [0], compiler_version [1], compiler_version [2]) ;
+      60             :     #endif
+      61             : 
+      62             :     #else
+      63             :     printf ("\nVanilla GraphBLAS: no GxB* extensions\n") ;
+      64             :     #endif
+      65             : 
+      66             :     // check the LAGraph version using both LAGraph.h and LAGraph_Version
+      67           1 :     printf ("LAGraph version %d.%d.%d (%s) from LAGraph.h\n",
+      68             :         LAGRAPH_VERSION_MAJOR, LAGRAPH_VERSION_MINOR, LAGRAPH_VERSION_UPDATE,
+      69             :         LAGRAPH_DATE) ;
+      70             : 
+      71             :     char version_date [LAGRAPH_MSG_LEN] ;
+      72           1 :     status = LAGraph_Version (ver, version_date, msg) ;
+      73           1 :     OK (status) ;
+      74             : 
+      75           1 :     printf ("LAGraph version %d.%d.%d (%s) from LAGraph_Version\n",
+      76             :         ver [0], ver [1], ver [2], version_date) ;
+      77             : 
+      78             :     // make sure the LAGraph version and date match
+      79           1 :     TEST_CHECK (ver [0] == LAGRAPH_VERSION_MAJOR) ;
+      80           1 :     TEST_CHECK (ver [1] == LAGRAPH_VERSION_MINOR) ;
+      81           1 :     TEST_CHECK (ver [2] == LAGRAPH_VERSION_UPDATE) ;
+      82           1 :     OK (strcmp (version_date, LAGRAPH_DATE)) ;
+      83             : 
+      84           1 :     OK (LAGraph_Finalize (msg)) ;
+      85           1 : }
+      86             : 
+      87             : //-----------------------------------------------------------------------------
+      88             : // TEST_LIST: the list of tasks for this entire test
+      89             : //-----------------------------------------------------------------------------
+      90             : 
+      91             : TEST_LIST =
+      92             : {
+      93             :     { "Init", test_Init },
+      94             :     // no brutal test: see test_Xinit
+      95             :     { NULL, NULL }
+      96             : } ;
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_Init_errors.c.func-sort-c.html b/src/test/test_Init_errors.c.func-sort-c.html new file mode 100644 index 0000000000..e0564a01f6 --- /dev/null +++ b/src/test/test_Init_errors.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_Init_errors.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_Init_errors.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1111100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_Init_errors1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_Init_errors.c.func.html b/src/test/test_Init_errors.c.func.html new file mode 100644 index 0000000000..7879b21cb5 --- /dev/null +++ b/src/test/test_Init_errors.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_Init_errors.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_Init_errors.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1111100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_Init_errors1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_Init_errors.c.gcov.html b/src/test/test_Init_errors.c.gcov.html new file mode 100644 index 0000000000..7acb58924d --- /dev/null +++ b/src/test/test_Init_errors.c.gcov.html @@ -0,0 +1,138 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_Init_errors.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_Init_errors.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1111100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph/src/test/test_Init_errors.c:  test LAGraph_Init and LAGraph_Finalize
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include "LAGraph_test.h"
+      19             : 
+      20             : //------------------------------------------------------------------------------
+      21             : // global variables
+      22             : //------------------------------------------------------------------------------
+      23             : 
+      24             : char msg [LAGRAPH_MSG_LEN] ;
+      25             : 
+      26             : //------------------------------------------------------------------------------
+      27             : // test_Init_errors:  test LAGraph_Init
+      28             : //------------------------------------------------------------------------------
+      29             : 
+      30           1 : void test_Init_errors (void)
+      31             : {
+      32             : 
+      33           1 :     int status = LAGraph_Init (msg) ;
+      34           1 :     OK (status) ;
+      35             :     int ver [3] ;
+      36             : 
+      37             :     // LAGraph_Init cannot be called twice
+      38           1 :     status = LAGraph_Init (msg) ;
+      39           1 :     printf ("\nstatus: %d msg: %s\n", status, msg) ;
+      40           1 :     TEST_CHECK (status != GrB_SUCCESS) ;
+      41             : 
+      42           1 :     OK (LAGraph_Finalize (msg)) ;
+      43             : 
+      44             :     // calling LAGraph_Finalize twice leads to undefined behavior;
+      45             :     // for SuiteSparse, it returns GrB_SUCCESS
+      46           1 :     status = LAGraph_Finalize (msg) ;
+      47           1 :     printf ("status %d\n", status) ;
+      48             :     #if LAGRAPH_SUITESPARSE
+      49           1 :     TEST_CHECK (status == GrB_SUCCESS) ;
+      50             :     #endif
+      51           1 : }
+      52             : 
+      53             : //-----------------------------------------------------------------------------
+      54             : // TEST_LIST: the list of tasks for this entire test
+      55             : //-----------------------------------------------------------------------------
+      56             : 
+      57             : TEST_LIST =
+      58             : {
+      59             :     { "Init_errors", test_Init_errors },
+      60             :     // no brutal test: see test_Xinit
+      61             :     { NULL, NULL }
+      62             : } ;
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_IsEqual.c.func-sort-c.html b/src/test/test_IsEqual.c.func-sort-c.html new file mode 100644 index 0000000000..43ccbfb84b --- /dev/null +++ b/src/test/test_IsEqual.c.func-sort-c.html @@ -0,0 +1,96 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_IsEqual.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_IsEqual.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:210210100.0 %
Date:2024-08-29 20:08:04Functions:66100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_IsEqual1
test_IsEqual_brutal1
test_IsEqual_failures1
test_Vector_IsEqual1
setup3
teardown3
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_IsEqual.c.func.html b/src/test/test_IsEqual.c.func.html new file mode 100644 index 0000000000..169ce52fcd --- /dev/null +++ b/src/test/test_IsEqual.c.func.html @@ -0,0 +1,96 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_IsEqual.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_IsEqual.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:210210100.0 %
Date:2024-08-29 20:08:04Functions:66100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
setup3
teardown3
test_IsEqual1
test_IsEqual_brutal1
test_IsEqual_failures1
test_Vector_IsEqual1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_IsEqual.c.gcov.html b/src/test/test_IsEqual.c.gcov.html new file mode 100644 index 0000000000..3804506399 --- /dev/null +++ b/src/test/test_IsEqual.c.gcov.html @@ -0,0 +1,528 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_IsEqual.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_IsEqual.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:210210100.0 %
Date:2024-08-29 20:08:04Functions:66100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph/src/test/test_IsEqual.c:  test LAGraph_*_IsEqual
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include "LAGraph_test.h"
+      19             : 
+      20             : //------------------------------------------------------------------------------
+      21             : // global variables
+      22             : //------------------------------------------------------------------------------
+      23             : 
+      24             : int status ;
+      25             : GrB_Info info ;
+      26             : char msg [LAGRAPH_MSG_LEN] ;
+      27             : GrB_Matrix A = NULL, B = NULL ;
+      28             : GrB_Vector u = NULL, v = NULL ;
+      29             : GrB_Type atype = NULL ;
+      30             : #define LEN 512
+      31             : char filename [LEN+1] ;
+      32             : char atype_name [LAGRAPH_MAX_NAME_LEN] ;
+      33             : 
+      34             : //------------------------------------------------------------------------------
+      35             : // test matrices
+      36             : //------------------------------------------------------------------------------
+      37             : 
+      38             : typedef struct
+      39             : {
+      40             :     bool isequal ;
+      41             :     bool isequal0 ;
+      42             :     const char *matrix1 ;
+      43             :     const char *matrix2 ;
+      44             : }
+      45             : matrix_info ;
+      46             : 
+      47             : const matrix_info files [ ] =
+      48             : {
+      49             :     //   iseq        matrix1             matrix2
+      50             :     {    0, 0, "A.mtx"           , "cover.mtx" },
+      51             :     {    0, 1, "A.mtx"           , "A2.mtx" },
+      52             :     {    0, 0, "cover.mtx"       , "cover_structure.mtx" },
+      53             :     {    0, 0, "cover.mtx"       , "cover_structure.mtx" },
+      54             :     {    1, 1, "LFAT5.mtx"       , "LFAT5.mtx" },
+      55             :     {    0, 0, "sample2.mtx"     , "sample.mtx" },
+      56             :     {    1, 1, "sample.mtx"      , "sample.mtx" },
+      57             :     {    1, 1, "matrix_int32.mtx", "matrix_int32.mtx" },
+      58             :     {    1, 1, "matrix_int32.mtx", "matrix_int32.mtx" },
+      59             :     {    0, 0, "matrix_int32.mtx", "matrix_int64.mtx" },
+      60             :     {    0, 0, "matrix_int32.mtx", "matrix_int64.mtx" },
+      61             :     {    1, 1, "west0067.mtx"    , "west0067_jumbled.mtx" },
+      62             :     {    1, 1, "west0067.mtx"    , "west0067_noheader.mtx"},
+      63             :     {    0, 0, "LFAT5.mtx"       , "west0067.mtx" },
+      64             :     {    0, 0, "empty.mtx"       , "full.mtx" },
+      65             :     {    1, 1, "full.mtx"        , "full_noheader.mtx" },
+      66             :     {    0, 0, ""                , "" }
+      67             : } ;
+      68             : 
+      69             : //------------------------------------------------------------------------------
+      70             : // setup: start a test
+      71             : //------------------------------------------------------------------------------
+      72             : 
+      73           3 : void setup (void)
+      74             : {
+      75           3 :     OK (LAGraph_Init (msg)) ;
+      76           3 : }
+      77             : 
+      78             : //------------------------------------------------------------------------------
+      79             : // teardown: finalize a test
+      80             : //------------------------------------------------------------------------------
+      81             : 
+      82           3 : void teardown (void)
+      83             : {
+      84           3 :     OK (LAGraph_Finalize (msg)) ;
+      85           3 : }
+      86             : 
+      87             : //------------------------------------------------------------------------------
+      88             : // test_IsEqual: test LAGraph_Matrix_IsEqual
+      89             : //------------------------------------------------------------------------------
+      90             : 
+      91           1 : void test_IsEqual (void)
+      92             : {
+      93             : 
+      94             :     //--------------------------------------------------------------------------
+      95             :     // start up the test
+      96             :     //--------------------------------------------------------------------------
+      97             : 
+      98           1 :     setup ( ) ;
+      99           1 :     printf ("\nTesting IsEqual:\n") ;
+     100             : 
+     101           1 :     for (int k = 0 ; ; k++)
+     102          16 :     {
+     103             : 
+     104             :         //----------------------------------------------------------------------
+     105             :         // load in the kth pair of files
+     106             :         //----------------------------------------------------------------------
+     107             : 
+     108          17 :         const char *aname = files [k].matrix1 ;
+     109          17 :         const char *bname = files [k].matrix2 ;
+     110          17 :         const bool isequal = files [k].isequal ;
+     111          17 :         const bool isequal0 = files [k].isequal0 ;
+     112          17 :         if (strlen (aname) == 0) break;
+     113          16 :         TEST_CASE (aname) ;
+     114          16 :         printf ("test %2d: %s %s\n", k, aname, bname) ;
+     115             : 
+     116          16 :         snprintf (filename, LEN, LG_DATA_DIR "%s", aname) ;
+     117          16 :         FILE *f = fopen (filename, "r") ;
+     118          16 :         TEST_CHECK (f != NULL) ;
+     119          16 :         OK (LAGraph_MMRead (&A, f, msg)) ;
+     120          16 :         OK (fclose (f)) ;
+     121          16 :         TEST_MSG ("Failed to load %s\n", aname) ;
+     122             :         GrB_Index ancols ;
+     123          16 :         OK (GrB_Matrix_ncols (&ancols, A)) ;
+     124             : 
+     125          16 :         snprintf (filename, LEN, LG_DATA_DIR "%s", bname) ;
+     126          16 :         f = fopen (filename, "r") ;
+     127          16 :         TEST_CHECK (f != NULL) ;
+     128          16 :         OK (LAGraph_MMRead (&B, f, msg)) ;
+     129          16 :         OK (fclose (f)) ;
+     130          16 :         TEST_MSG ("Failed to load %s\n", bname) ;
+     131             :         GrB_Index bncols ;
+     132          16 :         OK (GrB_Matrix_ncols (&bncols, B)) ;
+     133             : 
+     134             :         //----------------------------------------------------------------------
+     135             :         // compare the two matrices
+     136             :         //----------------------------------------------------------------------
+     137             : 
+     138          16 :         bool same = false ;
+     139             : 
+     140          16 :         OK (LAGraph_Matrix_IsEqual (&same, A, B, msg)) ;
+     141          16 :         TEST_CHECK (same == isequal) ;
+     142             : 
+     143          16 :         OK (LAGraph_Matrix_IsEqual (&same, A, A, msg)) ;
+     144          16 :         TEST_CHECK (same == true) ;
+     145             : 
+     146             :         //----------------------------------------------------------------------
+     147             :         // compare the two matrices with a given op
+     148             :         //----------------------------------------------------------------------
+     149             : 
+     150          16 :         OK (LAGraph_Matrix_TypeName (atype_name, A, msg)) ;
+     151          16 :         OK (LAGraph_TypeFromName (&atype, atype_name, msg)) ;
+     152             : 
+     153          16 :         GrB_BinaryOp op = NULL ;
+     154          16 :         if      (atype == GrB_BOOL  ) op = GrB_EQ_BOOL   ;
+     155          12 :         else if (atype == GrB_INT8  ) op = GrB_EQ_INT8   ;
+     156          12 :         else if (atype == GrB_INT16 ) op = GrB_EQ_INT16  ;
+     157          12 :         else if (atype == GrB_INT32 ) op = GrB_EQ_INT32  ;
+     158           5 :         else if (atype == GrB_INT64 ) op = GrB_EQ_INT64  ;
+     159           5 :         else if (atype == GrB_UINT8 ) op = GrB_EQ_UINT8  ;
+     160           5 :         else if (atype == GrB_UINT16) op = GrB_EQ_UINT16 ;
+     161           5 :         else if (atype == GrB_UINT32) op = GrB_EQ_UINT32 ;
+     162           5 :         else if (atype == GrB_UINT64) op = GrB_EQ_UINT64 ;
+     163           5 :         else if (atype == GrB_FP32  ) op = GrB_EQ_FP32   ;
+     164           5 :         else if (atype == GrB_FP64  ) op = GrB_EQ_FP64   ;
+     165             : 
+     166          16 :         OK (LAGraph_Matrix_IsEqualOp (&same, A, B, op, msg)) ;
+     167          16 :         TEST_CHECK (same == isequal) ;
+     168             : 
+     169          16 :         OK (LAGraph_Matrix_IsEqualOp (&same, A, A, op, msg)) ;
+     170          16 :         TEST_CHECK (same == true) ;
+     171             : 
+     172             :         //----------------------------------------------------------------------
+     173             :         // compare two vectors
+     174             :         //----------------------------------------------------------------------
+     175             : 
+     176          16 :         OK (GrB_Vector_new (&u, atype, ancols)) ;
+     177          16 :         OK (GrB_Vector_new (&v, atype, bncols)) ;
+     178          16 :         OK (GrB_Col_extract (u, NULL, NULL, A, GrB_ALL, ancols, 0,
+     179             :             GrB_DESC_T0)) ;
+     180          16 :         OK (GrB_Col_extract (v, NULL, NULL, B, GrB_ALL, bncols, 0,
+     181             :             GrB_DESC_T0)) ;
+     182             : 
+     183          16 :         OK (LAGraph_Vector_IsEqual (&same, u, v, msg)) ;
+     184          16 :         TEST_CHECK (same == isequal0) ;
+     185             : 
+     186          16 :         OK (LAGraph_Vector_IsEqual (&same, u, u, msg)) ;
+     187          16 :         TEST_CHECK (same == true) ;
+     188             : 
+     189          16 :         OK (LAGraph_Vector_IsEqual (&same, u, u, msg)) ;
+     190          16 :         TEST_CHECK (same == true) ;
+     191             : 
+     192          16 :         OK (GrB_free (&u)) ;
+     193          16 :         OK (GrB_free (&v)) ;
+     194          16 :         OK (GrB_free (&A)) ;
+     195          16 :         OK (GrB_free (&B)) ;
+     196             :     }
+     197             : 
+     198             :     //--------------------------------------------------------------------------
+     199             :     // finish the test
+     200             :     //--------------------------------------------------------------------------
+     201             : 
+     202           1 :     teardown ( ) ;
+     203           1 : }
+     204             : 
+     205             : //------------------------------------------------------------------------------
+     206             : // test_IsEqual_brutal:
+     207             : //------------------------------------------------------------------------------
+     208             : 
+     209             : #if LAGRAPH_SUITESPARSE
+     210           1 : void test_IsEqual_brutal (void)
+     211             : {
+     212             : 
+     213             :     //--------------------------------------------------------------------------
+     214             :     // start up the test
+     215             :     //--------------------------------------------------------------------------
+     216             : 
+     217           1 :     OK (LG_brutal_setup (msg)) ;
+     218           1 :     printf ("\nTesting IsEqual:\n") ;
+     219           1 :     GxB_set (GxB_BURBLE, false) ;
+     220             : 
+     221           1 :     for (int k = 0 ; ; k++)
+     222          16 :     {
+     223             : 
+     224             :         //----------------------------------------------------------------------
+     225             :         // load in the kth pair of files
+     226             :         //----------------------------------------------------------------------
+     227             : 
+     228          17 :         const char *aname = files [k].matrix1 ;
+     229          17 :         const char *bname = files [k].matrix2 ;
+     230          17 :         const bool isequal = files [k].isequal ;
+     231          17 :         const bool isequal0 = files [k].isequal0 ;
+     232          17 :         if (strlen (aname) == 0) break;
+     233          16 :         TEST_CASE (aname) ;
+     234          16 :         printf ("test %2d: %s %s\n", k, aname, bname) ;
+     235             : 
+     236          16 :         snprintf (filename, LEN, LG_DATA_DIR "%s", aname) ;
+     237          16 :         FILE *f = fopen (filename, "r") ;
+     238          16 :         TEST_CHECK (f != NULL) ;
+     239          16 :         OK (LAGraph_MMRead (&A, f, msg)) ;
+     240          16 :         OK (fclose (f)) ;
+     241          16 :         TEST_MSG ("Failed to load %s\n", aname) ;
+     242             :         GrB_Index ancols ;
+     243          16 :         OK (GrB_Matrix_ncols (&ancols, A)) ;
+     244             : 
+     245          16 :         snprintf (filename, LEN, LG_DATA_DIR "%s", bname) ;
+     246          16 :         f = fopen (filename, "r") ;
+     247          16 :         TEST_CHECK (f != NULL) ;
+     248          16 :         OK (LAGraph_MMRead (&B, f, msg)) ;
+     249          16 :         OK (fclose (f)) ;
+     250          16 :         TEST_MSG ("Failed to load %s\n", bname) ;
+     251             :         GrB_Index bncols ;
+     252          16 :         OK (GrB_Matrix_ncols (&bncols, B)) ;
+     253             : 
+     254             :         //----------------------------------------------------------------------
+     255             :         // compare the two matrices
+     256             :         //----------------------------------------------------------------------
+     257             : 
+     258          16 :         bool same = false ;
+     259             : 
+     260          59 :         LG_BRUTAL (LAGraph_Matrix_IsEqual (&same, A, B, msg)) ;
+     261          16 :         TEST_CHECK (same == isequal) ;
+     262             : 
+     263          16 :         LG_BRUTAL (LAGraph_Matrix_IsEqual (&same, A, A, msg)) ;
+     264          16 :         TEST_CHECK (same == true) ;
+     265             : 
+     266             :         //----------------------------------------------------------------------
+     267             :         // compare the two matrices with a given op
+     268             :         //----------------------------------------------------------------------
+     269             : 
+     270          16 :         LG_BRUTAL (LAGraph_Matrix_TypeName (atype_name, A, msg)) ;
+     271          16 :         LG_BRUTAL (LAGraph_TypeFromName (&atype, atype_name, msg)) ;
+     272             : 
+     273          16 :         GrB_BinaryOp op = NULL ;
+     274          16 :         if      (atype == GrB_BOOL  ) op = GrB_EQ_BOOL   ;
+     275          12 :         else if (atype == GrB_INT8  ) op = GrB_EQ_INT8   ;
+     276          12 :         else if (atype == GrB_INT16 ) op = GrB_EQ_INT16  ;
+     277          12 :         else if (atype == GrB_INT32 ) op = GrB_EQ_INT32  ;
+     278           5 :         else if (atype == GrB_INT64 ) op = GrB_EQ_INT64  ;
+     279           5 :         else if (atype == GrB_UINT8 ) op = GrB_EQ_UINT8  ;
+     280           5 :         else if (atype == GrB_UINT16) op = GrB_EQ_UINT16 ;
+     281           5 :         else if (atype == GrB_UINT32) op = GrB_EQ_UINT32 ;
+     282           5 :         else if (atype == GrB_UINT64) op = GrB_EQ_UINT64 ;
+     283           5 :         else if (atype == GrB_FP32  ) op = GrB_EQ_FP32   ;
+     284           5 :         else if (atype == GrB_FP64  ) op = GrB_EQ_FP64   ;
+     285             : 
+     286          79 :         LG_BRUTAL (LAGraph_Matrix_IsEqualOp (&same, A, B, op, msg)) ;
+     287          16 :         TEST_CHECK (same == isequal) ;
+     288             : 
+     289          16 :         LG_BRUTAL (LAGraph_Matrix_IsEqualOp (&same, A, A, op, msg)) ;
+     290          16 :         TEST_CHECK (same == true) ;
+     291             : 
+     292             :         //----------------------------------------------------------------------
+     293             :         // compare two vectors
+     294             :         //----------------------------------------------------------------------
+     295             : 
+     296          48 :         LG_BRUTAL (GrB_Vector_new (&u, atype, ancols)) ;
+     297          48 :         LG_BRUTAL (GrB_Vector_new (&v, atype, bncols)) ;
+     298          78 :         LG_BRUTAL (GrB_Col_extract (u, NULL, NULL, A, GrB_ALL, ancols, 0,
+     299             :             GrB_DESC_T0)) ;
+     300          86 :         LG_BRUTAL (GrB_Col_extract (v, NULL, NULL, B, GrB_ALL, bncols, 0,
+     301             :             GrB_DESC_T0)) ;
+     302             : 
+     303          63 :         LG_BRUTAL (LAGraph_Vector_IsEqual (&same, u, v, msg)) ;
+     304          16 :         TEST_CHECK (same == isequal0) ;
+     305             : 
+     306          16 :         LG_BRUTAL (LAGraph_Vector_IsEqual (&same, u, u, msg)) ;
+     307          16 :         TEST_CHECK (same == true) ;
+     308             : 
+     309          16 :         LG_BRUTAL (LAGraph_Vector_IsEqual (&same, u, u, msg)) ;
+     310          16 :         TEST_CHECK (same == true) ;
+     311             : 
+     312          16 :         LG_BRUTAL (GrB_free (&u)) ;
+     313          16 :         OK (GrB_free (&v)) ;
+     314          16 :         OK (GrB_free (&A)) ;
+     315          16 :         OK (GrB_free (&B)) ;
+     316             :     }
+     317             : 
+     318             :     //--------------------------------------------------------------------------
+     319             :     // finish the test
+     320             :     //--------------------------------------------------------------------------
+     321             : 
+     322           1 :     OK (LG_brutal_teardown (msg)) ;
+     323           1 : }
+     324             : #endif
+     325             : 
+     326             : //------------------------------------------------------------------------------
+     327             : // test_IsEqual_failures: test error handling of LAGraph_Matrix_IsEqual*
+     328             : //------------------------------------------------------------------------------
+     329             : 
+     330             : typedef int myint ;
+     331             : 
+     332           1 : void test_IsEqual_failures (void)
+     333             : {
+     334           1 :     setup ( ) ;
+     335           1 :     printf ("\nTest IsEqual: error handling and special cases\n") ;
+     336             : 
+     337           1 :     bool same = false ;
+     338             :     // not a failure, but a special case:
+     339           1 :     OK (LAGraph_Matrix_IsEqual (&same, NULL, NULL, msg)) ;
+     340           1 :     TEST_CHECK (same == true) ;
+     341             : 
+     342           1 :     OK (LAGraph_Vector_IsEqual (&same, NULL, NULL, msg)) ;
+     343           1 :     TEST_CHECK (same == true) ;
+     344             : 
+     345           1 :     int result = LAGraph_Matrix_IsEqual (NULL, NULL, NULL, msg) ;
+     346           1 :     TEST_CHECK (result == GrB_NULL_POINTER) ;
+     347           1 :     printf ("msg: %s\n", msg) ;
+     348             : 
+     349           1 :     result = LAGraph_Matrix_IsEqual (NULL, NULL, NULL, msg) ;
+     350           1 :     TEST_CHECK (result == GrB_NULL_POINTER) ;
+     351           1 :     printf ("msg: %s\n", msg) ;
+     352             : 
+     353           1 :     OK (GrB_Matrix_new (&A, GrB_BOOL, 2, 2)) ;
+     354           1 :     OK (GrB_Matrix_new (&B, GrB_BOOL, 2, 2)) ;
+     355             : 
+     356           1 :     OK (GrB_Vector_new (&u, GrB_BOOL, 2)) ;
+     357           1 :     OK (GrB_Vector_new (&v, GrB_BOOL, 2)) ;
+     358             : 
+     359           1 :     result = LAGraph_Matrix_IsEqual (NULL, A, B, msg) ;
+     360           1 :     TEST_CHECK (result == GrB_NULL_POINTER) ;
+     361           1 :     printf ("msg: %s\n", msg) ;
+     362             : 
+     363           1 :     result = LAGraph_Matrix_IsEqualOp (&same, A, B, NULL, msg) ;
+     364           1 :     TEST_CHECK (result == GrB_NULL_POINTER) ;
+     365           1 :     printf ("msg: %s\n", msg) ;
+     366             : 
+     367           1 :     result = LAGraph_Vector_IsEqual (NULL, u, v, msg) ;
+     368           1 :     TEST_CHECK (result == GrB_NULL_POINTER) ;
+     369           1 :     printf ("msg: %s\n", msg) ;
+     370             : 
+     371           1 :     result = LAGraph_Vector_IsEqualOp (&same, u, v, NULL, msg) ;
+     372           1 :     TEST_CHECK (result == GrB_NULL_POINTER) ;
+     373           1 :     printf ("msg: %s\n", msg) ;
+     374             : 
+     375           1 :     result = LAGraph_Matrix_IsEqual (NULL, A, B, msg) ;
+     376           1 :     TEST_CHECK (result == GrB_NULL_POINTER) ;
+     377           1 :     printf ("msg: %s\n", msg) ;
+     378             : 
+     379           1 :     result = LAGraph_Matrix_IsEqual (NULL, A, B, msg) ;
+     380           1 :     TEST_CHECK (result == GrB_NULL_POINTER) ;
+     381           1 :     printf ("msg: %s\n", msg) ;
+     382             : 
+     383           1 :     OK (LAGraph_Matrix_IsEqual (&same, A, B, msg)) ;
+     384           1 :     TEST_CHECK (same == true) ;
+     385             : 
+     386           1 :     OK (GrB_free (&u)) ;
+     387           1 :     OK (GrB_free (&v)) ;
+     388           1 :     OK (GrB_free (&A)) ;
+     389           1 :     OK (GrB_free (&B)) ;
+     390           1 :     teardown ( ) ;
+     391           1 : }
+     392             : 
+     393             : //------------------------------------------------------------------------------
+     394             : // test_Vector_IsEqual: test LAGraph_Vector_isEqual
+     395             : //------------------------------------------------------------------------------
+     396             : 
+     397           1 : void test_Vector_IsEqual (void)
+     398             : {
+     399           1 :     setup ( ) ;
+     400             : 
+     401           1 :     bool same = false ;
+     402           1 :     OK (LAGraph_Vector_IsEqualOp (&same, NULL, NULL, GrB_EQ_BOOL, msg)) ;
+     403           1 :     TEST_CHECK (same == true) ;
+     404             : 
+     405           1 :     OK (GrB_Vector_new (&u, GrB_BOOL, 3)) ;
+     406           1 :     OK (GrB_Vector_new (&v, GrB_BOOL, 2)) ;
+     407             : 
+     408           1 :     OK (LAGraph_Vector_IsEqualOp (&same, u, v, GrB_EQ_BOOL, msg)) ;
+     409           1 :     TEST_CHECK (same == false) ;
+     410             : 
+     411           1 :     OK (GrB_free (&u)) ;
+     412           1 :     OK (GrB_Vector_new (&u, GrB_BOOL, 2)) ;
+     413             : 
+     414           1 :     OK (LAGraph_Vector_IsEqualOp (&same, u, v, GrB_EQ_BOOL, msg)) ;
+     415           1 :     TEST_CHECK (same == true) ;
+     416             : 
+     417           1 :     OK (GrB_Vector_setElement (u, true, 0)) ;
+     418           1 :     OK (GrB_Vector_setElement (v, true, 1)) ;
+     419           1 :     OK (LAGraph_Vector_IsEqualOp (&same, u, v, GrB_EQ_BOOL, msg)) ;
+     420           1 :     TEST_CHECK (same == false) ;
+     421             : 
+     422           1 :     OK (LAGraph_Vector_IsEqual (&same, u, v, msg)) ;
+     423           1 :     TEST_CHECK (same == false) ;
+     424             : 
+     425           1 :     OK (GrB_free (&u)) ;
+     426           1 :     OK (GrB_free (&v)) ;
+     427             : 
+     428           1 :     OK (GrB_Vector_new (&u, GrB_BOOL, 3)) ;
+     429           1 :     OK (GrB_Vector_new (&v, GrB_FP32, 3)) ;
+     430           1 :     OK (LAGraph_Vector_IsEqual (&same, u, v, msg)) ;
+     431           1 :     TEST_CHECK (same == false) ;
+     432             : 
+     433           1 :     OK (GrB_free (&u)) ;
+     434           1 :     OK (GrB_free (&v)) ;
+     435             : 
+     436           1 :     teardown ( ) ;
+     437           1 : }
+     438             : 
+     439             : //------------------------------------------------------------------------------
+     440             : // TEST_LIST: the list of tasks for this entire test
+     441             : //------------------------------------------------------------------------------
+     442             : 
+     443             : TEST_LIST =
+     444             : {
+     445             :     { "IsEqual", test_IsEqual },
+     446             :     { "Vector_IsEqual", test_Vector_IsEqual },
+     447             :     { "IsEqual_failures", test_IsEqual_failures },
+     448             :     #if LAGRAPH_SUITESPARSE
+     449             :     { "IsEqual_brutal", test_IsEqual_brutal },
+     450             :     #endif
+     451             :     { NULL, NULL }
+     452             : } ;
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_KindName.c.func-sort-c.html b/src/test/test_KindName.c.func-sort-c.html new file mode 100644 index 0000000000..10c15c5315 --- /dev/null +++ b/src/test/test_KindName.c.func-sort-c.html @@ -0,0 +1,88 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_KindName.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_KindName.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:2424100.0 %
Date:2024-08-29 20:08:04Functions:44100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
setup1
teardown1
test_KindName1
test_KindName_brutal1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_KindName.c.func.html b/src/test/test_KindName.c.func.html new file mode 100644 index 0000000000..c54c701a99 --- /dev/null +++ b/src/test/test_KindName.c.func.html @@ -0,0 +1,88 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_KindName.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_KindName.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:2424100.0 %
Date:2024-08-29 20:08:04Functions:44100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
setup1
teardown1
test_KindName1
test_KindName_brutal1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_KindName.c.gcov.html b/src/test/test_KindName.c.gcov.html new file mode 100644 index 0000000000..e5ae71e0d9 --- /dev/null +++ b/src/test/test_KindName.c.gcov.html @@ -0,0 +1,174 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_KindName.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_KindName.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:2424100.0 %
Date:2024-08-29 20:08:04Functions:44100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph/src/test/test_KindName.c:  test LG_KindName
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include "LAGraph_test.h"
+      19             : #include "LG_internal.h"
+      20             : 
+      21             : //------------------------------------------------------------------------------
+      22             : // global variables
+      23             : //------------------------------------------------------------------------------
+      24             : 
+      25             : char msg [LAGRAPH_MSG_LEN] ;
+      26             : char name [LAGRAPH_MAX_NAME_LEN] ;
+      27             : 
+      28             : //------------------------------------------------------------------------------
+      29             : // setup: start a test
+      30             : //------------------------------------------------------------------------------
+      31             : 
+      32           1 : void setup (void)
+      33             : {
+      34           1 :     OK (LAGraph_Init (msg)) ;
+      35           1 : }
+      36             : 
+      37             : //------------------------------------------------------------------------------
+      38             : // teardown: finalize a test
+      39             : //------------------------------------------------------------------------------
+      40             : 
+      41           1 : void teardown (void)
+      42             : {
+      43           1 :     OK (LAGraph_Finalize (msg)) ;
+      44           1 : }
+      45             : 
+      46             : //------------------------------------------------------------------------------
+      47             : // test_KindName:  test LG_KindName
+      48             : //------------------------------------------------------------------------------
+      49             : 
+      50           1 : void test_KindName (void)
+      51             : {
+      52           1 :     setup ( ) ;
+      53             : 
+      54           1 :     OK (LG_KindName (name, LAGraph_ADJACENCY_UNDIRECTED, msg)) ;
+      55           1 :     OK (strcmp (name, "undirected")) ;
+      56             : 
+      57           1 :     OK (LG_KindName (name, LAGraph_ADJACENCY_DIRECTED, msg)) ;
+      58           1 :     OK (strcmp (name, "directed")) ;
+      59             : 
+      60           1 :     OK (LG_KindName (name, LAGRAPH_UNKNOWN, msg)) ;
+      61           1 :     OK (strcmp (name, "unknown")) ;
+      62             : 
+      63           1 :     TEST_CHECK (LG_KindName (name, 42, msg) == GrB_INVALID_VALUE) ;
+      64           1 :     printf ("\nmsg: %s\n", msg) ;
+      65             : 
+      66           1 :     teardown ( ) ;
+      67           1 : }
+      68             : 
+      69             : //------------------------------------------------------------------------------
+      70             : // test_KindName_brutal
+      71             : //------------------------------------------------------------------------------
+      72             : 
+      73             : // LG_KindName currently doesn't do any mallocs so this test is not
+      74             : // strictly necessary, but it's simple to include here.  It serves as a very
+      75             : // simple use-case of the brutal testing mechanism.
+      76             : 
+      77             : #if LAGRAPH_SUITESPARSE
+      78           1 : void test_KindName_brutal (void)
+      79             : {
+      80           1 :     OK (LG_brutal_setup (msg)) ;
+      81           1 :     LG_BRUTAL (LG_KindName (name, LAGraph_ADJACENCY_UNDIRECTED, msg)) ;
+      82           1 :     OK (strcmp (name, "undirected")) ;
+      83           1 :     OK (LG_brutal_teardown (msg)) ;
+      84           1 : }
+      85             : #endif
+      86             : 
+      87             : //-----------------------------------------------------------------------------
+      88             : // TEST_LIST: the list of tasks for this entire test
+      89             : //-----------------------------------------------------------------------------
+      90             : 
+      91             : TEST_LIST =
+      92             : {
+      93             :     { "KindName", test_KindName },
+      94             :     #if LAGRAPH_SUITESPARSE
+      95             :     { "KindName_brutal", test_KindName_brutal },
+      96             :     #endif
+      97             :     { NULL, NULL }
+      98             : } ;
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_MMRead.c.func-sort-c.html b/src/test/test_MMRead.c.func-sort-c.html new file mode 100644 index 0000000000..99cf690102 --- /dev/null +++ b/src/test/test_MMRead.c.func-sort-c.html @@ -0,0 +1,112 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_MMRead.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_MMRead.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:287287100.0 %
Date:2024-08-29 20:08:04Functions:1010100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_MMRead1
test_MMReadWrite_brutal1
test_MMRead_failures1
test_MMWrite1
test_MMWrite_failures1
test_array_pattern1
test_jumbled1
test_karate1
setup6
teardown6
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_MMRead.c.func.html b/src/test/test_MMRead.c.func.html new file mode 100644 index 0000000000..746ca445c8 --- /dev/null +++ b/src/test/test_MMRead.c.func.html @@ -0,0 +1,112 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_MMRead.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_MMRead.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:287287100.0 %
Date:2024-08-29 20:08:04Functions:1010100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
setup6
teardown6
test_MMRead1
test_MMReadWrite_brutal1
test_MMRead_failures1
test_MMWrite1
test_MMWrite_failures1
test_array_pattern1
test_jumbled1
test_karate1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_MMRead.c.gcov.html b/src/test/test_MMRead.c.gcov.html new file mode 100644 index 0000000000..043249fc0a --- /dev/null +++ b/src/test/test_MMRead.c.gcov.html @@ -0,0 +1,859 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_MMRead.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_MMRead.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:287287100.0 %
Date:2024-08-29 20:08:04Functions:1010100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph/src/test/test_MMRead.c:  test LAGraph_MMRead and LAGraph_MMWrite
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include "LAGraph_test.h"
+      19             : #include "LG_internal.h"
+      20             : 
+      21             : //------------------------------------------------------------------------------
+      22             : // global variables
+      23             : //------------------------------------------------------------------------------
+      24             : 
+      25             : int status ;
+      26             : GrB_Info info ;
+      27             : char msg [LAGRAPH_MSG_LEN] ;
+      28             : GrB_Matrix A = NULL, B = NULL ;
+      29             : const char *name, *date ;
+      30             : int ver [3] ;
+      31             : GrB_Index nrows, ncols, nvals ;
+      32             : #define LEN 512
+      33             : char filename [LEN+1] ;
+      34             : char atype_name [LAGRAPH_MAX_NAME_LEN] ;
+      35             : char btype_name [LAGRAPH_MAX_NAME_LEN] ;
+      36             : 
+      37             : //------------------------------------------------------------------------------
+      38             : // test matrices
+      39             : //------------------------------------------------------------------------------
+      40             : 
+      41             : typedef struct
+      42             : {
+      43             :     GrB_Index nrows ;
+      44             :     GrB_Index ncols ;
+      45             :     GrB_Index nvals ;
+      46             :     const char *type ;
+      47             :     const char *name ;
+      48             : }
+      49             : matrix_info ;
+      50             : 
+      51             : const matrix_info files [ ] =
+      52             : {
+      53             :     // nrows ncols nvals type         name
+      54             :     {    7,    7,    30, "bool",    "A.mtx" },
+      55             :     {    7,    7,    12, "int32_t", "cover.mtx" },
+      56             :     {    7,    7,    12, "bool",    "cover_structure.mtx" },
+      57             :     { 1138, 1138,  7450, "bool",    "jagmesh7.mtx" },
+      58             :     {    8,    8,    18, "bool",    "ldbc-cdlp-directed-example.mtx" },
+      59             :     {    8,    8,    24, "bool",    "ldbc-cdlp-undirected-example.mtx" },
+      60             :     {   10,   10,    17, "bool",    "ldbc-directed-example-bool.mtx" },
+      61             :     {   10,   10,    17, "double",  "ldbc-directed-example.mtx" },
+      62             :     {   10,   10,    17, "bool",    "ldbc-directed-example-unweighted.mtx" },
+      63             :     {    9,    9,    24, "bool",    "ldbc-undirected-example-bool.mtx" },
+      64             :     {    9,    9,    24, "double",  "ldbc-undirected-example.mtx" },
+      65             :     {    9,    9,    24, "bool",    "ldbc-undirected-example-unweighted.mtx"},
+      66             :     {   10,   10,    30, "int64_t", "ldbc-wcc-example.mtx" },
+      67             :     {   14,   14,    46, "double",  "LFAT5.mtx" },
+      68             :     {    6,    6,     8, "int64_t", "msf1.mtx" },
+      69             :     {    8,    8,    12, "int64_t", "msf2.mtx" },
+      70             :     {    5,    5,     7, "int64_t", "msf3.mtx" },
+      71             :     {    8,    8,    28, "bool",    "sample2.mtx" },
+      72             :     {    8,    8,    12, "bool",    "sample.mtx" },
+      73             :     {   64,    1,    64, "int64_t", "sources_7.mtx" },
+      74             :     { 1000, 1000,  3996, "double",  "olm1000.mtx" },
+      75             :     { 2003, 2003, 83883, "double",  "bcsstk13.mtx" },
+      76             :     { 2500, 2500, 12349, "double",  "cryg2500.mtx" },
+      77             :     {    6,    6,    10, "int64_t", "tree-example.mtx" },
+      78             :     {   67,   67,   294, "double",  "west0067.mtx" },
+      79             :     {   27,   51,   102, "double",  "lp_afiro.mtx" },
+      80             :     {   27,   51,   102, "bool",    "lp_afiro_structure.mtx" },
+      81             :     {   34,   34,   156, "bool",    "karate.mtx" },
+      82             :     {    7,    7,    12, "bool",    "matrix_bool.mtx" },
+      83             :     {    7,    7,    12, "int8_t",  "matrix_int8.mtx" },
+      84             :     {    7,    7,    12, "int16_t", "matrix_int16.mtx" },
+      85             :     {    7,    7,    12, "int32_t", "matrix_int32.mtx" },
+      86             :     {    7,    7,    12, "int64_t", "matrix_int64.mtx" },
+      87             :     {    7,    7,    12, "uint8_t", "matrix_uint8.mtx" },
+      88             :     {    7,    7,    12, "uint16_t","matrix_uint16.mtx" },
+      89             :     {    7,    7,    12, "uint32_t","matrix_uint32.mtx" },
+      90             :     {    7,    7,    12, "uint64_t","matrix_uint64.mtx" },
+      91             :     {    7,    7,    12, "float",   "matrix_fp32.mtx" },
+      92             :     {    7,    7,    12, "bool",    "matrix_fp32_structure.mtx" },
+      93             :     {    7,    7,    12, "double",  "matrix_fp64.mtx" },
+      94             :     {   67,   67,   294, "double",  "west0067_jumbled.mtx" },
+      95             :     {    6,    6,    20, "float",    "skew_fp32.mtx" },
+      96             :     {    6,    6,    20, "double",  "skew_fp64.mtx" },
+      97             :     {    6,    6,    20, "int8_t",  "skew_int8.mtx" },
+      98             :     {    6,    6,    20, "int16_t", "skew_int16.mtx" },
+      99             :     {    6,    6,    20, "int32_t", "skew_int32.mtx" },
+     100             :     {    6,    6,    20, "int64_t", "skew_int64.mtx" },
+     101             :     {    7,    7,    12, "int32_t", "structure.mtx" },
+     102             :     {    3,    3,     9, "double",  "full.mtx" },
+     103             :     {    4,    4,    16, "double",  "full_symmetric.mtx" },
+     104             :     {    3,    4,     0, "int32_t", "empty.mtx" },
+     105             :     { 0, 0, 0, "", "" },
+     106             : } ;
+     107             : 
+     108             : //------------------------------------------------------------------------------
+     109             : // setup: start a test
+     110             : //------------------------------------------------------------------------------
+     111             : 
+     112           6 : void setup (void)
+     113             : {
+     114           6 :     printf ("\nsetup: %s\n", __FILE__) ;
+     115           6 :     printf ("data is in [%s]\n", LG_DATA_DIR) ;
+     116           6 :     OK (LAGraph_Init (msg)) ;
+     117             :     #if LAGRAPH_SUITESPARSE
+     118           6 :     OK (GxB_get (GxB_LIBRARY_NAME, &name)) ;
+     119           6 :     OK (GxB_get (GxB_LIBRARY_DATE, &date)) ;
+     120           6 :     OK (GxB_get (GxB_LIBRARY_VERSION, ver)) ;
+     121             :     #endif
+     122           6 : }
+     123             : 
+     124             : //------------------------------------------------------------------------------
+     125             : // teardown: finalize a test
+     126             : //------------------------------------------------------------------------------
+     127             : 
+     128           6 : void teardown (void)
+     129             : {
+     130             :     #if LAGRAPH_SUITESPARSE
+     131           6 :     printf ("\n%s %d.%d.%d (%s)\n", name, ver [0], ver [1], ver [2], date) ;
+     132             :     #endif
+     133           6 :     OK (GrB_free (&A)) ;
+     134           6 :     OK (GrB_free (&B)) ;
+     135           6 :     TEST_CHECK (A == NULL) ;
+     136           6 :     TEST_CHECK (B == NULL) ;
+     137           6 :     OK (LAGraph_Finalize (msg)) ;
+     138           6 : }
+     139             : 
+     140             : //------------------------------------------------------------------------------
+     141             : // test_MMRead:  read a set of matrices, check their stats, and write them out
+     142             : //------------------------------------------------------------------------------
+     143             : 
+     144           1 : void test_MMRead (void)
+     145             : {
+     146             : 
+     147             :     //--------------------------------------------------------------------------
+     148             :     // start up the test
+     149             :     //--------------------------------------------------------------------------
+     150             : 
+     151           1 :     setup ( ) ;
+     152             : 
+     153           1 :     for (int k = 0 ; ; k++)
+     154          51 :     {
+     155             : 
+     156             :         //----------------------------------------------------------------------
+     157             :         // load in the kth file
+     158             :         //----------------------------------------------------------------------
+     159             : 
+     160          52 :         const char *aname = files [k].name ;
+     161          52 :         if (strlen (aname) == 0) break;
+     162          51 :         TEST_CASE (aname) ;
+     163          51 :         printf ("\n============= %2d: %s\n", k, aname) ;
+     164          51 :         snprintf (filename, LEN, LG_DATA_DIR "%s", aname) ;
+     165          51 :         FILE *f = fopen (filename, "r") ;
+     166          51 :         TEST_CHECK (f != NULL) ;
+     167          51 :         OK (LAGraph_MMRead (&A, f, msg)) ;
+     168          51 :         OK (fclose (f)) ;
+     169          51 :         TEST_MSG ("Failed to load %s\n", aname) ;
+     170             : 
+     171             :         //----------------------------------------------------------------------
+     172             :         // check its stats
+     173             :         //----------------------------------------------------------------------
+     174             : 
+     175          51 :         OK (GrB_Matrix_nrows (&nrows, A)) ;
+     176          51 :         OK (GrB_Matrix_ncols (&ncols, A)) ;
+     177          51 :         OK (GrB_Matrix_nvals (&nvals, A)) ;
+     178          51 :         TEST_CHECK (nrows == files [k].nrows) ;
+     179          51 :         TEST_CHECK (ncols == files [k].ncols) ;
+     180          51 :         TEST_CHECK (nvals == files [k].nvals) ;
+     181             : 
+     182          51 :         OK (LAGraph_Matrix_TypeName (atype_name, A, msg)) ;
+     183          51 :         printf ("types: [%s] [%s]\n", atype_name, files [k].type) ;
+     184          51 :         TEST_CHECK (MATCHNAME (atype_name, files [k].type)) ;
+     185          51 :         TEST_MSG ("Stats are wrong for %s\n", aname) ;
+     186             : 
+     187             :         //----------------------------------------------------------------------
+     188             :         // pretty-print the matrix
+     189             :         //----------------------------------------------------------------------
+     190             : 
+     191         204 :         for (int pr = 0 ; pr <= 2 ; pr++)
+     192             :         {
+     193         153 :             printf ("\nPretty-print %s: pr=%d:\n", aname, pr) ;
+     194         153 :             LAGraph_PrintLevel prl = pr ;
+     195         153 :             OK (LAGraph_Matrix_Print (A, prl, stdout, msg)) ;
+     196             :         }
+     197             : 
+     198             :         //----------------------------------------------------------------------
+     199             :         // write it to a temporary file
+     200             :         //----------------------------------------------------------------------
+     201             : 
+     202          51 :         f = tmpfile ( ) ;
+     203          51 :         OK (LAGraph_MMWrite (A, f, NULL, msg)) ;
+     204          51 :         TEST_MSG ("Failed to write %s to a temp file\n", aname) ;
+     205             : 
+     206             :         //----------------------------------------------------------------------
+     207             :         // load it back in again
+     208             :         //----------------------------------------------------------------------
+     209             : 
+     210          51 :         rewind (f) ;
+     211          51 :         OK (LAGraph_MMRead (&B, f, msg)) ;
+     212          51 :         TEST_MSG ("Failed to load %s from a temp file\n", aname) ;
+     213          51 :         OK (fclose (f)) ;       // close and delete the temporary file
+     214             : 
+     215             :         //----------------------------------------------------------------------
+     216             :         // ensure A and B are the same
+     217             :         //----------------------------------------------------------------------
+     218             : 
+     219          51 :         OK (LAGraph_Matrix_TypeName (btype_name, B, msg)) ;
+     220          51 :         TEST_CHECK (MATCHNAME (atype_name, btype_name)) ;
+     221             :         bool ok ;
+     222          51 :         OK (LAGraph_Matrix_IsEqual (&ok, A, B, msg)) ;
+     223          51 :         TEST_CHECK (ok) ;
+     224          51 :         TEST_MSG ("Failed test for equality, file: %s\n", aname) ;
+     225             : 
+     226             :         //----------------------------------------------------------------------
+     227             :         // free workspace
+     228             :         //----------------------------------------------------------------------
+     229             : 
+     230          51 :         OK (GrB_free (&A)) ;
+     231          51 :         OK (GrB_free (&B)) ;
+     232             :     }
+     233             : 
+     234             :     //--------------------------------------------------------------------------
+     235             :     // finish the test
+     236             :     //--------------------------------------------------------------------------
+     237             : 
+     238           1 :     teardown ( ) ;
+     239           1 : }
+     240             : 
+     241             : //-----------------------------------------------------------------------------
+     242             : // test_karate: read in karate graph from a file and compare it known graph
+     243             : //-----------------------------------------------------------------------------
+     244             : 
+     245           1 : void test_karate (void)
+     246             : {
+     247             : 
+     248             :     //--------------------------------------------------------------------------
+     249             :     // start up the test
+     250             :     //--------------------------------------------------------------------------
+     251             : 
+     252           1 :     setup ( ) ;
+     253             : 
+     254             :     //--------------------------------------------------------------------------
+     255             :     // load in the data/karate.mtx file as the matrix A
+     256             :     //--------------------------------------------------------------------------
+     257             : 
+     258           1 :     FILE *f = fopen (LG_DATA_DIR "karate.mtx", "r") ;
+     259           1 :     TEST_CHECK (f != NULL) ;
+     260           1 :     OK (LAGraph_MMRead (&A, f, msg)) ;
+     261           1 :     OK (LAGraph_Matrix_TypeName (atype_name, A, msg)) ;
+     262           1 :     TEST_CHECK (MATCHNAME (atype_name, "bool")) ;
+     263           1 :     OK (fclose (f)) ;
+     264           1 :     OK (LAGraph_Matrix_Print (A, LAGraph_SHORT, stdout, msg)) ;
+     265           1 :     TEST_MSG ("Loading of A matrix failed: karate matrix") ;
+     266             : 
+     267             :     //--------------------------------------------------------------------------
+     268             :     // load in the matrix defined by graph_zachary_karate.h as the matrix B
+     269             :     //--------------------------------------------------------------------------
+     270             : 
+     271           1 :     OK (GrB_Matrix_new (&B, GrB_BOOL, ZACHARY_NUM_NODES, ZACHARY_NUM_NODES)) ;
+     272           1 :     OK (GrB_Matrix_build (B, ZACHARY_I, ZACHARY_J, ZACHARY_V,
+     273             :         ZACHARY_NUM_EDGES, GrB_LOR)) ;
+     274           1 :     OK (LAGraph_Matrix_Print (B, LAGraph_SHORT, stdout, msg)) ;
+     275           1 :     TEST_MSG ("Loading of B matrix failed: karate matrix") ;
+     276             : 
+     277             :     //--------------------------------------------------------------------------
+     278             :     // ensure A and B are the same
+     279             :     //--------------------------------------------------------------------------
+     280             : 
+     281             :     bool ok ;
+     282           1 :     OK (LAGraph_Matrix_IsEqual (&ok, A, B, msg)) ;
+     283           1 :     TEST_CHECK (ok) ;
+     284           1 :     TEST_MSG ("Test for A and B equal failed: karate matrix") ;
+     285             : 
+     286             :     //--------------------------------------------------------------------------
+     287             :     // free workspace and finish the test
+     288             :     //--------------------------------------------------------------------------
+     289             : 
+     290           1 :     OK (GrB_free (&A)) ;
+     291           1 :     OK (GrB_free (&B)) ;
+     292           1 :     teardown ( ) ;
+     293           1 : }
+     294             : 
+     295             : //-----------------------------------------------------------------------------
+     296             : // test_failures: test for failure modes of LAGraph_MMRead and MMWrite
+     297             : //-----------------------------------------------------------------------------
+     298             : 
+     299             : typedef struct
+     300             : {
+     301             :     int error ;
+     302             :     const char *name ;
+     303             : }
+     304             : mangled_matrix_info ;
+     305             : 
+     306             : const mangled_matrix_info mangled_files [ ] =
+     307             : {
+     308             : //  error             filename              how the matrix is mangled
+     309             :     LAGRAPH_IO_ERROR, "mangled1.mtx",       // bad header
+     310             :     LAGRAPH_IO_ERROR, "mangled2.mtx",       // bad header
+     311             :     LAGRAPH_IO_ERROR, "mangled3.mtx",       // bad type
+     312             :     GrB_NOT_IMPLEMENTED, "complex.mtx",     // valid complex, but not supported
+     313             :     LAGRAPH_IO_ERROR, "mangled4.mtx",       // bad format
+     314             :     LAGRAPH_IO_ERROR, "mangled5.mtx",       // invalid format options
+     315             :     LAGRAPH_IO_ERROR, "mangled6.mtx",       // invalid format options
+     316             :     LAGRAPH_IO_ERROR, "mangled7.mtx",       // invalid GraphBLAS type
+     317             :     LAGRAPH_IO_ERROR, "mangled8.mtx",       // invalid first line
+     318             :     LAGRAPH_IO_ERROR, "mangled9.mtx",       // symmetric and rectangular
+     319             :     LAGRAPH_IO_ERROR, "mangled10.mtx",      // truncated
+     320             :     LAGRAPH_IO_ERROR, "mangled11.mtx",      // entries mangled
+     321             :     LAGRAPH_IO_ERROR, "mangled12.mtx",      // entries mangled
+     322             :     GrB_INDEX_OUT_OF_BOUNDS, "mangled13.mtx",// indices out of range
+     323             :     GrB_INVALID_VALUE, "mangled14.mtx",     // duplicate entries
+     324             :     LAGRAPH_IO_ERROR, "mangled_bool.mtx",   // entry value out of range
+     325             :     LAGRAPH_IO_ERROR, "mangled_int8.mtx",   // entry value out of range
+     326             :     LAGRAPH_IO_ERROR, "mangled_int16.mtx",  // entry value out of range
+     327             :     LAGRAPH_IO_ERROR, "mangled_int32.mtx",  // entry value out of range
+     328             :     LAGRAPH_IO_ERROR, "mangled_uint8.mtx",  // entry value out of range
+     329             :     LAGRAPH_IO_ERROR, "mangled_uint16.mtx", // entry value out of range
+     330             :     LAGRAPH_IO_ERROR, "mangled_uint32.mtx", // entry value out of range
+     331             :     LAGRAPH_IO_ERROR, "mangled_skew.mtx",   // unsigned skew invalid
+     332             :     GrB_NOT_IMPLEMENTED, "mangled15.mtx",   // complex not supported
+     333             :     GrB_NOT_IMPLEMENTED, "mangled16.mtx",   // complex not supported
+     334             :     LAGRAPH_IO_ERROR, "mangled_format.mtx", // "array pattern" invalid
+     335             :     0, "",
+     336             : } ;
+     337             : 
+     338           1 : void test_MMRead_failures (void)
+     339             : {
+     340           1 :     setup ( ) ;
+     341           1 :     printf ("\nTesting error handling of LAGraph_MMRead when giving it "
+     342             :         "mangled matrices:\n") ;
+     343             : 
+     344             :     // input arguments are NULL
+     345           1 :     TEST_CHECK (LAGraph_MMRead (NULL, NULL, msg) == GrB_NULL_POINTER) ;
+     346           1 :     printf ("msg: [%s]\n", msg) ;
+     347           1 :     TEST_CHECK (LAGraph_MMRead (&A, NULL, msg) == GrB_NULL_POINTER) ;
+     348           1 :     printf ("msg: [%s]\n", msg) ;
+     349             : 
+     350             :     // matrix files are mangled in some way, or unsupported
+     351           1 :     for (int k = 0 ; ; k++)
+     352          26 :     {
+     353          27 :         const char *aname = mangled_files [k].name ;
+     354          27 :         if (strlen (aname) == 0) break;
+     355          26 :         TEST_CASE (aname) ;
+     356          26 :         int error = mangled_files [k].error ;
+     357          26 :         snprintf (filename, LEN, LG_DATA_DIR "%s", aname) ;
+     358          26 :         printf ("file: [%s]\n", filename) ;
+     359          26 :         FILE *f = fopen (filename, "r") ;
+     360          26 :         TEST_CHECK (f != NULL) ;
+     361          26 :         int status = LAGraph_MMRead (&A, f, msg) ;
+     362          26 :         printf ("error expected: %d %d [%s]\n", error, status, msg) ;
+     363          26 :         TEST_CHECK (status == error) ;
+     364          26 :         OK (fclose (f)) ;
+     365          26 :         TEST_CHECK (A == NULL) ;
+     366             :     }
+     367             : 
+     368           1 :     teardown ( ) ;
+     369           1 : }
+     370             : 
+     371             : //-----------------------------------------------------------------------------
+     372             : // test_jumbled: test reading a jumbled matrix
+     373             : //-----------------------------------------------------------------------------
+     374             : 
+     375           1 : void test_jumbled (void)
+     376             : {
+     377             : 
+     378             :     //--------------------------------------------------------------------------
+     379             :     // start up the test
+     380             :     //--------------------------------------------------------------------------
+     381             : 
+     382           1 :     setup ( ) ;
+     383             : 
+     384             :     //--------------------------------------------------------------------------
+     385             :     // load in the data/west0067.mtx file as the matrix A
+     386             :     //--------------------------------------------------------------------------
+     387             : 
+     388           1 :     FILE *f = fopen (LG_DATA_DIR "west0067.mtx", "r") ;
+     389           1 :     TEST_CHECK (f != NULL) ;
+     390           1 :     OK (LAGraph_MMRead (&A, f, msg)) ;
+     391           1 :     OK (LAGraph_Matrix_TypeName (atype_name, A, msg)) ;
+     392           1 :     TEST_CHECK (MATCHNAME (atype_name, "double")) ;
+     393           1 :     OK (fclose (f)) ;
+     394           1 :     TEST_MSG ("Loading of west0067.mtx failed") ;
+     395             : 
+     396             :     //--------------------------------------------------------------------------
+     397             :     // load in the data/west0067_jumbled.mtx file as the matrix B
+     398             :     //--------------------------------------------------------------------------
+     399             : 
+     400           1 :     f = fopen (LG_DATA_DIR "west0067_jumbled.mtx", "r") ;
+     401           1 :     TEST_CHECK (f != NULL) ;
+     402           1 :     OK (LAGraph_MMRead (&B, f, msg)) ;
+     403           1 :     OK (LAGraph_Matrix_TypeName (btype_name, B, msg)) ;
+     404           1 :     TEST_CHECK (MATCHNAME (btype_name, "double")) ;
+     405           1 :     OK (fclose (f)) ;
+     406           1 :     TEST_MSG ("Loading of west0067_jumbled.mtx failed") ;
+     407             : 
+     408             :     //--------------------------------------------------------------------------
+     409             :     // ensure A and B are the same
+     410             :     //--------------------------------------------------------------------------
+     411             : 
+     412             :     bool ok ;
+     413           1 :     OK (LAGraph_Matrix_IsEqual (&ok, A, B, msg)) ;
+     414           1 :     TEST_CHECK (ok) ;
+     415           1 :     TEST_MSG ("Test for A and B equal failed: west0067_jumbled.mtx matrix") ;
+     416             : 
+     417             :     //--------------------------------------------------------------------------
+     418             :     // free workspace and finish the test
+     419             :     //--------------------------------------------------------------------------
+     420             : 
+     421           1 :     OK (GrB_free (&A)) ;
+     422           1 :     OK (GrB_free (&B)) ;
+     423           1 :     teardown ( ) ;
+     424           1 : }
+     425             : 
+     426             : //-----------------------------------------------------------------------------
+     427             : // test_MMWrite: test LAGraph_MMWrite
+     428             : //-----------------------------------------------------------------------------
+     429             : 
+     430             : const char* files_for_MMWrite [ ] =
+     431             : {
+     432             :     "west0067.mtx",
+     433             :     "full.mtx",
+     434             :     "cover.mtx",
+     435             :     ""
+     436             : } ;
+     437             : 
+     438           1 : void test_MMWrite (void)
+     439             : {
+     440             : 
+     441             :     //--------------------------------------------------------------------------
+     442             :     // start up the test
+     443             :     //--------------------------------------------------------------------------
+     444             : 
+     445           1 :     setup ( ) ;
+     446             : 
+     447           1 :     for (int k = 0 ; ; k++)
+     448           3 :     {
+     449             : 
+     450             :         //----------------------------------------------------------------------
+     451             :         // load in the kth file
+     452             :         //----------------------------------------------------------------------
+     453             : 
+     454           4 :         const char *aname = files_for_MMWrite [k] ;
+     455           4 :         if (strlen (aname) == 0) break;
+     456           3 :         TEST_CASE (aname) ;
+     457           3 :         printf ("\n============= %2d: %s\n", k, aname) ;
+     458           3 :         snprintf (filename, LEN, LG_DATA_DIR "%s", aname) ;
+     459           3 :         FILE *f = fopen (filename, "r") ;
+     460           3 :         TEST_CHECK (f != NULL) ;
+     461           3 :         OK (LAGraph_MMRead (&A, f, msg)) ;
+     462           3 :         OK (fclose (f)) ;
+     463           3 :         TEST_MSG ("Failed to load %s\n", aname) ;
+     464           3 :         OK (LAGraph_Matrix_TypeName (atype_name, A, msg)) ;
+     465             : 
+     466             :         //----------------------------------------------------------------------
+     467             :         // create a file for comments
+     468             :         //----------------------------------------------------------------------
+     469             : 
+     470           3 :         FILE *fcomments = fopen (LG_DATA_DIR "comments.txt", "wb") ;
+     471           3 :         TEST_CHECK (fcomments != NULL) ;
+     472           3 :         fprintf (fcomments, " comments for %s\n", aname) ;
+     473           3 :         fprintf (fcomments, " this file was created by test_MMRead.c\n") ;
+     474           3 :         fclose (fcomments) ;
+     475           3 :         TEST_MSG ("Failed to create comments.txt") ;
+     476             : 
+     477             :         //----------------------------------------------------------------------
+     478             :         // write the matrix to the data/comments_*.mtx file
+     479             :         //----------------------------------------------------------------------
+     480             : 
+     481           3 :         snprintf (filename, LEN, LG_DATA_DIR "comments_%s", aname) ;
+     482           3 :         fcomments = fopen (LG_DATA_DIR "comments.txt", "r") ;
+     483           3 :         FILE *foutput = fopen (filename, "wb") ;
+     484           3 :         TEST_CHECK (foutput != NULL) ;
+     485           3 :         TEST_CHECK (fcomments != NULL) ;
+     486           3 :         OK (LAGraph_MMWrite (A, foutput, fcomments, msg)) ;
+     487           3 :         fclose (fcomments) ;
+     488           3 :         fclose (foutput) ;
+     489           3 :         TEST_MSG ("Failed to create %s", filename) ;
+     490             : 
+     491             :         //----------------------------------------------------------------------
+     492             :         // load in the data/comments_.mtx file as the matrix B
+     493             :         //----------------------------------------------------------------------
+     494             : 
+     495           3 :         f = fopen (filename, "r") ;
+     496           3 :         TEST_CHECK (f != NULL) ;
+     497           3 :         OK (LAGraph_MMRead (&B, f, msg)) ;
+     498             : 
+     499           3 :         OK (LAGraph_Matrix_TypeName (btype_name, B, msg)) ;
+     500           3 :         TEST_CHECK (MATCHNAME (atype_name, btype_name)) ;
+     501           3 :         OK (fclose (f)) ;
+     502           3 :         TEST_MSG ("Loading of %s failed", filename) ;
+     503             : 
+     504             :         //----------------------------------------------------------------------
+     505             :         // ensure A and B are the same
+     506             :         //----------------------------------------------------------------------
+     507             : 
+     508             :         bool ok ;
+     509           3 :         OK (LAGraph_Matrix_IsEqual (&ok, A, B, msg)) ;
+     510           3 :         TEST_CHECK (ok) ;
+     511           3 :         TEST_MSG ("Test for A and B equal failed: %s", filename) ;
+     512             : 
+     513             :         //----------------------------------------------------------------------
+     514             :         // write a nan
+     515             :         //----------------------------------------------------------------------
+     516             : 
+     517           3 :         if (k == 0)
+     518             :         {
+     519           1 :             OK (GrB_Matrix_setElement (A, NAN, 0, 0)) ;
+     520             :             double a ;
+     521           1 :             OK (GrB_Matrix_extractElement (&a, A, 0, 0)) ;
+     522           1 :             TEST_CHECK (isnan (a)) ;
+     523           1 :             foutput = fopen (filename, "wb") ;
+     524           1 :             fcomments = fopen (LG_DATA_DIR "comments.txt", "r") ;
+     525           1 :             TEST_CHECK (foutput != NULL) ;
+     526           1 :             OK (LAGraph_MMWrite (A, foutput, fcomments, msg)) ;
+     527           1 :             fclose (fcomments) ;
+     528           1 :             fclose (foutput) ;
+     529           1 :             OK (GrB_free (&A)) ;
+     530           1 :             f = fopen (filename, "r") ;
+     531           1 :             TEST_CHECK (f != NULL) ;
+     532           1 :             OK (LAGraph_MMRead (&A, f, msg)) ;
+     533           1 :             fclose (f) ;
+     534           1 :             a = 0 ;
+     535           1 :             OK (GrB_Matrix_extractElement (&a, A, 0, 0)) ;
+     536           1 :             TEST_CHECK (isnan (a)) ;
+     537             :         }
+     538             : 
+     539             :         //----------------------------------------------------------------------
+     540             :         // free workspace
+     541             :         //----------------------------------------------------------------------
+     542             : 
+     543           3 :         OK (GrB_free (&A)) ;
+     544           3 :         OK (GrB_free (&B)) ;
+     545             :     }
+     546             : 
+     547             :     //--------------------------------------------------------------------------
+     548             :     // finish the test
+     549             :     //--------------------------------------------------------------------------
+     550             : 
+     551           1 :     teardown ( ) ;
+     552           1 : }
+     553             : 
+     554             : //-----------------------------------------------------------------------------
+     555             : // test_MMWrite_failures: test error handling of LAGraph_MMWrite
+     556             : //-----------------------------------------------------------------------------
+     557             : 
+     558             : typedef int mytype ;
+     559             : 
+     560           1 : void test_MMWrite_failures (void)
+     561             : {
+     562           1 :     setup ( ) ;
+     563           1 :     GrB_Type atype = NULL ;
+     564           1 :     printf ("\nTesting error handling of LAGraph_MMWrite\n") ;
+     565             : 
+     566             :     // input arguments are NULL
+     567           1 :     TEST_CHECK (LAGraph_MMWrite (NULL, NULL, NULL, msg) == GrB_NULL_POINTER) ;
+     568           1 :     printf ("msg: [%s]\n", msg) ;
+     569             : 
+     570             :     // attempt to print a matrix with a user-defined type, which should fail
+     571           1 :     FILE *f = tmpfile ( ) ;
+     572           1 :     TEST_CHECK (f != NULL) ;
+     573           1 :     OK (GrB_Type_new (&atype, sizeof (mytype))) ;
+     574           1 :     OK (GrB_Matrix_new (&A, atype, 4, 4)) ;
+     575           1 :     int status = LAGraph_Matrix_Print (A, LAGraph_COMPLETE, stdout, msg) ;
+     576           1 :     printf ("msg: [%s]\n", msg) ;
+     577           1 :     TEST_CHECK (status == GrB_NOT_IMPLEMENTED) ;
+     578           1 :     status = LAGraph_MMWrite (A, f, NULL, msg) ;
+     579           1 :     printf ("msg: %d [%s]\n", status, msg) ;
+     580           1 :     TEST_CHECK (status == GrB_NOT_IMPLEMENTED) ;
+     581           1 :     OK (GrB_free (&atype)) ;
+     582           1 :     OK (GrB_free (&A)) ;
+     583           1 :     OK (fclose (f)) ;       // close and delete the temporary file
+     584             : 
+     585           1 :     teardown ( ) ;
+     586           1 : }
+     587             : 
+     588             : //------------------------------------------------------------------------------
+     589             : // test_MMReadWrite_brutal
+     590             : //------------------------------------------------------------------------------
+     591             : 
+     592             : #if LAGRAPH_SUITESPARSE
+     593           1 : void test_MMReadWrite_brutal (void)
+     594             : {
+     595             : 
+     596             :     //--------------------------------------------------------------------------
+     597             :     // start up the test
+     598             :     //--------------------------------------------------------------------------
+     599             : 
+     600           1 :     OK (LG_brutal_setup (msg)) ;
+     601             : 
+     602           1 :     for (int k = 0 ; ; k++)
+     603          51 :     {
+     604             : 
+     605             :         //----------------------------------------------------------------------
+     606             :         // load in the kth file
+     607             :         //----------------------------------------------------------------------
+     608             : 
+     609          52 :         const char *aname = files [k].name ;
+     610          52 :         if (strlen (aname) == 0) break;
+     611          51 :         TEST_CASE (aname) ;
+     612          51 :         printf ("\n============= %2d: %s\n", k, aname) ;
+     613          51 :         snprintf (filename, LEN, LG_DATA_DIR "%s", aname) ;
+     614          51 :         FILE *f = fopen (filename, "r") ;
+     615          51 :         TEST_CHECK (f != NULL) ;
+     616          51 :         OK (LAGraph_MMRead (&A, f, msg)) ;
+     617          51 :         OK (fclose (f)) ;
+     618          51 :         TEST_MSG ("Failed to load %s\n", aname) ;
+     619          51 :         printf ("\n") ;
+     620             : 
+     621             :         //----------------------------------------------------------------------
+     622             :         // write it to a temporary file
+     623             :         //----------------------------------------------------------------------
+     624             : 
+     625          51 :         for (int nbrutal = 0 ; ; nbrutal++)
+     626        1220 :         {
+     627             :             /* allow for only nbrutal mallocs before 'failing' */
+     628        1271 :             printf (".") ;
+     629        1271 :             LG_brutal = nbrutal ;
+     630             :             /* try the method with brutal malloc */
+     631        1271 :             f = tmpfile ( ) ;   // create a new temp file for each trial
+     632        1271 :             int brutal_result = LAGraph_MMWrite (A, f, NULL, msg) ;
+     633        1271 :             if (brutal_result >= 0)
+     634             :             {
+     635             :                 /* the method finally succeeded */
+     636             :                 // leave the file open for the next phase
+     637          51 :                 printf (" MMWrite ok: %d mallocs\n", nbrutal) ;
+     638          51 :                 break ;
+     639             :             }
+     640        1220 :             OK (fclose (f)) ;   // close and delete the file and try again
+     641        1220 :             if (nbrutal > 10000) { printf ("Infinite!\n") ; abort ( ) ; }
+     642             :         }
+     643          51 :         LG_brutal = -1 ;  /* turn off brutal mallocs */
+     644             : 
+     645             :         //----------------------------------------------------------------------
+     646             :         // load it back in again
+     647             :         //----------------------------------------------------------------------
+     648             : 
+     649          51 :         for (int nbrutal = 0 ; ; nbrutal++)
+     650         688 :         {
+     651             :             /* allow for only nbrutal mallocs before 'failing' */
+     652         739 :             printf (".") ;
+     653         739 :             LG_brutal = nbrutal ;
+     654             :             /* try the method with brutal malloc */
+     655         739 :             rewind (f) ;        // rewind the temp file for each trial
+     656         739 :             int brutal_result = LAGraph_MMRead (&B, f, msg) ;
+     657         739 :             if (brutal_result >= 0)
+     658             :             {
+     659             :                 /* the method finally succeeded */
+     660          51 :                 printf (" MMRead ok: %d mallocs\n", nbrutal) ;
+     661          51 :                 OK (fclose (f)) ;   // finally close and delete the temp file
+     662          51 :                 break ;
+     663             :             }
+     664         688 :             if (nbrutal > 10000) { printf ("Infinite!\n") ; abort ( ) ; }
+     665             :         }
+     666          51 :         LG_brutal = -1 ;  /* turn off brutal mallocs */
+     667             : 
+     668             :         //----------------------------------------------------------------------
+     669             :         // ensure A and B are the same
+     670             :         //----------------------------------------------------------------------
+     671             : 
+     672          51 :         OK (LAGraph_Matrix_TypeName (atype_name, A, msg)) ;
+     673          51 :         OK (LAGraph_Matrix_TypeName (btype_name, B, msg)) ;
+     674          51 :         TEST_CHECK (MATCHNAME (atype_name, btype_name)) ;
+     675             : 
+     676             :         bool ok ;
+     677          51 :         OK (GrB_Matrix_wait (A, GrB_MATERIALIZE)) ;
+     678          51 :         OK (GrB_Matrix_wait (B, GrB_MATERIALIZE)) ;
+     679         325 :         LG_BRUTAL (LAGraph_Matrix_IsEqual (&ok, A, B, msg)) ;
+     680          51 :         TEST_CHECK (ok) ;
+     681          51 :         TEST_MSG ("Failed test for equality, file: %s\n", aname) ;
+     682             : 
+     683             :         //----------------------------------------------------------------------
+     684             :         // free workspace
+     685             :         //----------------------------------------------------------------------
+     686             : 
+     687          51 :         OK (GrB_free (&A)) ;
+     688          51 :         OK (GrB_free (&B)) ;
+     689             :     }
+     690             : 
+     691             :     //--------------------------------------------------------------------------
+     692             :     // finish the test
+     693             :     //--------------------------------------------------------------------------
+     694             : 
+     695           1 :     OK (LG_brutal_teardown (msg)) ;
+     696           1 : }
+     697             : #endif
+     698             : 
+     699             : //------------------------------------------------------------------------------
+     700             : // test_array_pattern
+     701             : //------------------------------------------------------------------------------
+     702             : 
+     703           1 : void test_array_pattern ( )
+     704             : {
+     705             : 
+     706             :     //--------------------------------------------------------------------------
+     707             :     // start up the test
+     708             :     //--------------------------------------------------------------------------
+     709             : 
+     710           1 :     OK (LG_brutal_setup (msg)) ;
+     711             : 
+     712             :     //--------------------------------------------------------------------------
+     713             :     // construct a dense 3-by-3 matrix of all 1's (iso-valued)
+     714             :     //--------------------------------------------------------------------------
+     715             : 
+     716           1 :     OK (GrB_Matrix_new (&A, GrB_INT64, 3, 3)) ;
+     717           1 :     OK (GrB_Matrix_assign_INT64 (A, NULL, NULL, 1, GrB_ALL, 3, GrB_ALL, 3,
+     718             :         NULL)) ;
+     719           1 :     OK (GrB_Matrix_wait (A, GrB_MATERIALIZE)) ;
+     720           1 :     printf ("\nA matrix:\n") ;
+     721           1 :     OK (LAGraph_Matrix_Print (A, LAGraph_COMPLETE, stdout, msg)) ;
+     722             : 
+     723             :     //--------------------------------------------------------------------------
+     724             :     // write it to a temporary file
+     725             :     //--------------------------------------------------------------------------
+     726             : 
+     727           1 :     FILE *f = tmpfile ( ) ; // fopen ("/tmp/mine.mtx", "wb") ;
+     728           1 :     OK (LAGraph_MMWrite (A, f, NULL, msg)) ;
+     729           1 :     TEST_MSG ("Failed to write matrix to a temp file\n") ;
+     730             : //  OK (fclose (f)) ;
+     731             : 
+     732             :     //--------------------------------------------------------------------------
+     733             :     // load it back in again
+     734             :     //--------------------------------------------------------------------------
+     735             : 
+     736           1 :     rewind (f) ;
+     737             : //  f = fopen ("/tmp/mine.mtx", "r") ;
+     738           1 :     OK (LAGraph_MMRead (&B, f, msg)) ;
+     739           1 :     TEST_MSG ("Failed to load matrix from a temp file\n") ;
+     740           1 :     OK (fclose (f)) ;       // close and delete the temporary file
+     741             : 
+     742           1 :     printf ("\nB matrix:\n") ;
+     743           1 :     OK (LAGraph_Matrix_Print (B, LAGraph_COMPLETE, stdout, msg)) ;
+     744             : 
+     745             :     //--------------------------------------------------------------------------
+     746             :     // ensure A and B are the same
+     747             :     //--------------------------------------------------------------------------
+     748             : 
+     749           1 :     OK (LAGraph_Matrix_TypeName (btype_name, B, msg)) ;
+     750           1 :     TEST_CHECK (MATCHNAME ("int64_t", btype_name)) ;
+     751             :     bool ok ;
+     752           1 :     OK (LAGraph_Matrix_IsEqual (&ok, A, B, msg)) ;
+     753           1 :     TEST_CHECK (ok) ;
+     754           1 :     TEST_MSG ("Failed test for equality, dense 3-by-3\n") ;
+     755             : 
+     756             :     //--------------------------------------------------------------------------
+     757             :     // finish the test
+     758             :     //--------------------------------------------------------------------------
+     759             : 
+     760           1 :     OK (GrB_free (&A)) ;
+     761           1 :     OK (GrB_free (&B)) ;
+     762             : 
+     763           1 :     OK (LG_brutal_teardown (msg)) ;
+     764           1 : }
+     765             : 
+     766             : //-----------------------------------------------------------------------------
+     767             : // TEST_LIST: the list of tasks for this entire test
+     768             : //-----------------------------------------------------------------------------
+     769             : 
+     770             : TEST_LIST =
+     771             : {
+     772             :     { "MMRead", test_MMRead },
+     773             :     { "karate", test_karate },
+     774             :     { "MMRead_failures", test_MMRead_failures },
+     775             :     { "jumbled", test_jumbled },
+     776             :     { "MMWrite", test_MMWrite },
+     777             :     { "MMWrite_failures", test_MMWrite_failures },
+     778             :     #if LAGRAPH_SUITESPARSE
+     779             :     { "MMReadWrite_brutal", test_MMReadWrite_brutal },
+     780             :     #endif
+     781             :     { "array_pattern", test_array_pattern },
+     782             :     { NULL, NULL }
+     783             : } ;
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_Malloc.c.func-sort-c.html b/src/test/test_Malloc.c.func-sort-c.html new file mode 100644 index 0000000000..0ae987b9e4 --- /dev/null +++ b/src/test/test_Malloc.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_Malloc.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_Malloc.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:4646100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_malloc1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_Malloc.c.func.html b/src/test/test_Malloc.c.func.html new file mode 100644 index 0000000000..a31142e94e --- /dev/null +++ b/src/test/test_Malloc.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_Malloc.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_Malloc.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:4646100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_malloc1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_Malloc.c.gcov.html b/src/test/test_Malloc.c.gcov.html new file mode 100644 index 0000000000..926ab06904 --- /dev/null +++ b/src/test/test_Malloc.c.gcov.html @@ -0,0 +1,197 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_Malloc.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_Malloc.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:4646100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //-----------------------------------------------------------------------------
+       2             : // LAGraph/src/test/test_Malloc.c: test LAGraph_Malloc and related methods
+       3             : //-----------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //-----------------------------------------------------------------------------
+      17             : 
+      18             : #include "LAGraph_test.h"
+      19             : char msg [LAGRAPH_MSG_LEN] ;
+      20             : 
+      21             : //-----------------------------------------------------------------------------
+      22             : // test_malloc
+      23             : //-----------------------------------------------------------------------------
+      24             : 
+      25           1 : void test_malloc (void)
+      26             : {
+      27             :     char msg [LAGRAPH_MSG_LEN] ;
+      28           1 :     OK (LAGraph_Init (msg)) ;
+      29             : 
+      30             :     char *p ;
+      31           1 :     OK (LAGraph_Malloc ((void **) &p, 42, sizeof (char), msg)) ;
+      32          43 :     for (int k = 0 ; k < 42 ; k++)
+      33             :     {
+      34          42 :         p [k] = (char) k ;
+      35             :     }
+      36           1 :     OK (LAGraph_Free ((void **) &p, msg)) ;
+      37           1 :     TEST_CHECK (p == NULL) ;
+      38             : 
+      39           1 :     size_t huge = 1 + SIZE_MAX/2 ;
+      40             : 
+      41             :     if (sizeof (size_t) >= sizeof (uint64_t))
+      42             :     {
+      43           1 :         LAGraph_Malloc ((void **) &p, huge, sizeof (char), msg) ;
+      44           1 :         TEST_CHECK (p == NULL) ;    // was FAIL
+      45           1 :         LAGraph_Calloc ((void **) &p, huge, sizeof (char), msg) ;
+      46           1 :         TEST_CHECK (p == NULL) ;    // was FAIL
+      47             :     }
+      48             : 
+      49           1 :     OK (LAGraph_Calloc ((void **) &p, 42, sizeof (char), msg)) ;
+      50          43 :     for (int k = 0 ; k < 42 ; k++)
+      51             :     {
+      52          42 :         TEST_CHECK (*p == '\0') ;
+      53             :     }
+      54           1 :     OK (LAGraph_Free ((void **) &p, msg)) ;
+      55           1 :     TEST_CHECK (p == NULL) ;
+      56             : 
+      57           1 :     OK (LAGraph_Free (NULL, NULL)) ;
+      58             : 
+      59           1 :     LAGraph_Calloc_function = NULL ;
+      60             : 
+      61           1 :     OK (LAGraph_Calloc ((void **) &p, 42, sizeof (char), msg)) ;
+      62           1 :     TEST_CHECK (p != NULL) ;
+      63          43 :     for (int k = 0 ; k < 42 ; k++)
+      64             :     {
+      65          42 :         TEST_CHECK (*p == '\0') ;
+      66             :     }
+      67             : 
+      68           1 :     OK (LAGraph_Realloc ((void **) &p, 100, 42, sizeof (char), msg)) ;
+      69          43 :     for (int k = 0 ; k < 42 ; k++)
+      70             :     {
+      71          42 :         TEST_CHECK (*p == '\0') ;
+      72             :     }
+      73          59 :     for (int k = 42 ; k < 100 ; k++)
+      74             :     {
+      75          58 :         p [k] = (char) k ;
+      76             :     }
+      77           1 :     OK (LAGraph_Free ((void **) &p, NULL)) ;
+      78           1 :     TEST_CHECK (p == NULL) ;
+      79             : 
+      80           1 :     OK (LAGraph_Realloc ((void **) &p, 80, 0, sizeof (char), msg)) ;
+      81             : 
+      82             :     if (sizeof (size_t) >= sizeof (uint64_t))
+      83             :     {
+      84           1 :         int s = (LAGraph_Realloc ((void **) &p, huge, 80, sizeof (char), msg)) ;
+      85           1 :         TEST_CHECK (s == GrB_OUT_OF_MEMORY) ;  // was FAIL
+      86             :     }
+      87             : 
+      88          81 :     for (int k = 0 ; k < 80 ; k++)
+      89             :     {
+      90          80 :         p [k] = (char) k ;
+      91             :     }
+      92             : 
+      93           1 :     OK (LAGraph_Realloc ((void **) &p, 80, 80, sizeof (char), msg)) ;
+      94          81 :     for (int k = 0 ; k < 80 ; k++)
+      95             :     {
+      96          80 :         TEST_CHECK (p [k] == (char) k) ;    // was FAIL
+      97             :     }
+      98             : 
+      99           1 :     LAGraph_Realloc_function = NULL ;
+     100             : 
+     101           1 :     OK (LAGraph_Realloc ((void **) &p, 100, 80, sizeof (char), msg)) ;
+     102          81 :     for (int k = 0 ; k < 80 ; k++)
+     103             :     {
+     104          80 :         TEST_CHECK (p [k] == (char) k) ;    // was FAIL
+     105             :     }
+     106             : 
+     107           1 :     OK (LAGraph_Free ((void **) &p, NULL)) ;
+     108           1 :     TEST_CHECK (p == NULL) ;
+     109             : 
+     110           1 :     OK (LAGraph_Finalize (msg)) ;
+     111           1 : }
+     112             : 
+     113             : //-----------------------------------------------------------------------------
+     114             : // TEST_LIST: the list of tasks for this entire test
+     115             : //-----------------------------------------------------------------------------
+     116             : 
+     117             : TEST_LIST = {
+     118             :     {"test_malloc", test_malloc},
+     119             :     // no brutal test needed
+     120             :     {NULL, NULL}
+     121             : };
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_Matrix_Structure.c.func-sort-c.html b/src/test/test_Matrix_Structure.c.func-sort-c.html new file mode 100644 index 0000000000..ed8e22f3a6 --- /dev/null +++ b/src/test/test_Matrix_Structure.c.func-sort-c.html @@ -0,0 +1,92 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_Matrix_Structure.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_Matrix_Structure.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:7878100.0 %
Date:2024-08-29 20:08:04Functions:55100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_Matrix_Structure1
test_Matrix_Structure_brutal1
test_Matrix_Structure_failures1
setup2
teardown2
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_Matrix_Structure.c.func.html b/src/test/test_Matrix_Structure.c.func.html new file mode 100644 index 0000000000..b94b4cc766 --- /dev/null +++ b/src/test/test_Matrix_Structure.c.func.html @@ -0,0 +1,92 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_Matrix_Structure.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_Matrix_Structure.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:7878100.0 %
Date:2024-08-29 20:08:04Functions:55100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
setup2
teardown2
test_Matrix_Structure1
test_Matrix_Structure_brutal1
test_Matrix_Structure_failures1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_Matrix_Structure.c.gcov.html b/src/test/test_Matrix_Structure.c.gcov.html new file mode 100644 index 0000000000..3c35bc0609 --- /dev/null +++ b/src/test/test_Matrix_Structure.c.gcov.html @@ -0,0 +1,262 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_Matrix_Structure.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_Matrix_Structure.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:7878100.0 %
Date:2024-08-29 20:08:04Functions:55100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph/src/test/test_Matrix_Structure.c:  test LAGraph_Matrix_Structure
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include "LAGraph_test.h"
+      19             : #include "LG_internal.h"
+      20             : 
+      21             : //------------------------------------------------------------------------------
+      22             : // global variables
+      23             : //------------------------------------------------------------------------------
+      24             : 
+      25             : char msg [LAGRAPH_MSG_LEN] ;
+      26             : GrB_Matrix A = NULL, B = NULL, C = NULL ;
+      27             : GrB_Vector w = NULL, u = NULL, z = NULL ;
+      28             : #define LEN 512
+      29             : char filename [LEN+1] ;
+      30             : char btype_name [LAGRAPH_MAX_NAME_LEN] ;
+      31             : 
+      32             : //------------------------------------------------------------------------------
+      33             : // setup: start a test
+      34             : //------------------------------------------------------------------------------
+      35             : 
+      36           2 : void setup (void)
+      37             : {
+      38           2 :     OK (LAGraph_Init (msg)) ;
+      39           2 : }
+      40             : 
+      41             : //------------------------------------------------------------------------------
+      42             : // teardown: finalize a test
+      43             : //------------------------------------------------------------------------------
+      44             : 
+      45           2 : void teardown (void)
+      46             : {
+      47           2 :     OK (LAGraph_Finalize (msg)) ;
+      48           2 : }
+      49             : 
+      50             : //------------------------------------------------------------------------------
+      51             : // test_Matrix_Structure:  test LAGraph_Matrix_Structure
+      52             : //------------------------------------------------------------------------------
+      53             : 
+      54             : const char *files [ ] =
+      55             : {
+      56             :     "cover",
+      57             :     "lp_afiro",
+      58             :     "matrix_fp32",
+      59             :     ""
+      60             : } ;
+      61             : 
+      62           1 : void test_Matrix_Structure (void)
+      63             : {
+      64           1 :     setup ( ) ;
+      65             : 
+      66           1 :     for (int k = 0 ; ; k++)
+      67           3 :     {
+      68             :         // load the valued matrix as A
+      69           4 :         const char *aname = files [k] ;
+      70           4 :         if (strlen (aname) == 0) break;
+      71           3 :         TEST_CASE (aname) ;
+      72           3 :         snprintf (filename, LEN, LG_DATA_DIR "%s.mtx", aname) ;
+      73           3 :         FILE *f = fopen (filename, "r") ;
+      74           3 :         TEST_CHECK (f != NULL) ;
+      75           3 :         OK (LAGraph_MMRead (&A, f, msg)) ;
+      76           3 :         OK (fclose (f)) ;
+      77           3 :         TEST_MSG ("Loading of valued matrix failed") ;
+      78             : 
+      79             :         // load the structure as B
+      80           3 :         snprintf (filename, LEN, LG_DATA_DIR "%s_structure.mtx", aname) ;
+      81           3 :         f = fopen (filename, "r") ;
+      82           3 :         TEST_CHECK (f != NULL) ;
+      83           3 :         OK (LAGraph_MMRead (&B, f, msg)) ;
+      84           3 :         OK (LAGraph_Matrix_TypeName (btype_name, B, msg)) ;
+      85           3 :         TEST_CHECK (MATCHNAME (btype_name, "bool")) ;
+      86           3 :         OK (fclose (f)) ;
+      87           3 :         TEST_MSG ("Loading of structure matrix failed") ;
+      88             : 
+      89             :         // C = structure (A)
+      90           3 :         OK (LAGraph_Matrix_Structure (&C, A, msg)) ;
+      91             : 
+      92             :         // ensure B and C are the same
+      93             :         bool ok ;
+      94           3 :         OK (LAGraph_Matrix_IsEqual (&ok, C, B, msg)) ;
+      95           3 :         TEST_CHECK (ok) ;
+      96           3 :         TEST_MSG ("Test for C and B equal failed") ;
+      97             : 
+      98           3 :         OK (GrB_free (&A)) ;
+      99           3 :         OK (GrB_free (&B)) ;
+     100           3 :         OK (GrB_free (&C)) ;
+     101             :     }
+     102           1 :     teardown ( ) ;
+     103           1 : }
+     104             : 
+     105             : //------------------------------------------------------------------------------
+     106             : // test_Matrix_Structure_brutal
+     107             : //------------------------------------------------------------------------------
+     108             : 
+     109             : #if LAGRAPH_SUITESPARSE
+     110           1 : void test_Matrix_Structure_brutal (void)
+     111             : {
+     112           1 :     OK (LG_brutal_setup (msg)) ;
+     113             : 
+     114           1 :     for (int k = 0 ; ; k++)
+     115           3 :     {
+     116             :         // load the valued matrix as A
+     117           4 :         const char *aname = files [k] ;
+     118           4 :         if (strlen (aname) == 0) break;
+     119           3 :         TEST_CASE (aname) ;
+     120           3 :         snprintf (filename, LEN, LG_DATA_DIR "%s.mtx", aname) ;
+     121           3 :         FILE *f = fopen (filename, "r") ;
+     122           3 :         TEST_CHECK (f != NULL) ;
+     123           3 :         OK (LAGraph_MMRead (&A, f, msg)) ;
+     124           3 :         OK (fclose (f)) ;
+     125           3 :         TEST_MSG ("Loading of valued matrix failed") ;
+     126             : 
+     127             :         // load the structure as B
+     128           3 :         snprintf (filename, LEN, LG_DATA_DIR "%s_structure.mtx", aname) ;
+     129           3 :         f = fopen (filename, "r") ;
+     130           3 :         TEST_CHECK (f != NULL) ;
+     131           3 :         OK (LAGraph_MMRead (&B, f, msg)) ;
+     132           3 :         OK (LAGraph_Matrix_TypeName (btype_name, B, msg)) ;
+     133           3 :         TEST_CHECK (MATCHNAME (btype_name, "bool")) ;
+     134           3 :         OK (fclose (f)) ;
+     135           3 :         TEST_MSG ("Loading of structure matrix failed") ;
+     136             : 
+     137             :         // C = structure (A)
+     138          22 :         LG_BRUTAL (LAGraph_Matrix_Structure (&C, A, msg)) ;
+     139             : 
+     140             :         // ensure B and C are the same
+     141             :         bool ok ;
+     142           3 :         OK (LAGraph_Matrix_IsEqual (&ok, C, B, msg)) ;
+     143           3 :         TEST_CHECK (ok) ;
+     144           3 :         TEST_MSG ("Test for C and B equal failed") ;
+     145             : 
+     146           3 :         OK (GrB_free (&A)) ;
+     147           3 :         OK (GrB_free (&B)) ;
+     148           3 :         OK (GrB_free (&C)) ;
+     149             :     }
+     150           1 :     OK (LG_brutal_teardown (msg)) ;
+     151           1 : }
+     152             : #endif
+     153             : 
+     154             : //------------------------------------------------------------------------------
+     155             : // test_Matrix_Structure_failures: test LAGraph_Matrix_Structure error handling
+     156             : //------------------------------------------------------------------------------
+     157             : 
+     158           1 : void test_Matrix_Structure_failures (void)
+     159             : {
+     160           1 :     setup ( ) ;
+     161             : 
+     162           1 :     C = NULL ;
+     163           1 :     int result = LAGraph_Matrix_Structure (NULL, NULL, msg) ;
+     164           1 :     TEST_CHECK (result == GrB_NULL_POINTER) ;
+     165           1 :     printf ("\nmsg: [%s]\n", msg) ;
+     166           1 :     result = LAGraph_Matrix_Structure (&C, NULL, msg) ;
+     167           1 :     TEST_CHECK (result == GrB_NULL_POINTER) ;
+     168           1 :     printf ("msg: [%s]\n", msg) ;
+     169           1 :     TEST_CHECK (C == NULL) ;
+     170             : 
+     171           1 :     teardown ( ) ;
+     172           1 : }
+     173             : 
+     174             : //-----------------------------------------------------------------------------
+     175             : // TEST_LIST: the list of tasks for this entire test
+     176             : //-----------------------------------------------------------------------------
+     177             : 
+     178             : TEST_LIST =
+     179             : {
+     180             :     { "Matrix_Structure", test_Matrix_Structure },
+     181             :     { "Matrix_Structure_failures", test_Matrix_Structure_failures },
+     182             :     #if LAGRAPH_SUITESPARSE
+     183             :     { "Matrix_Structure_brutal", test_Matrix_Structure_brutal },
+     184             :     #endif
+     185             :     { NULL, NULL }
+     186             : } ;
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_Multiply_size_t.c.func-sort-c.html b/src/test/test_Multiply_size_t.c.func-sort-c.html new file mode 100644 index 0000000000..ed8803e2b8 --- /dev/null +++ b/src/test/test_Multiply_size_t.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_Multiply_size_t.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_Multiply_size_t.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1212100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_multiply1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_Multiply_size_t.c.func.html b/src/test/test_Multiply_size_t.c.func.html new file mode 100644 index 0000000000..c74beb485a --- /dev/null +++ b/src/test/test_Multiply_size_t.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_Multiply_size_t.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_Multiply_size_t.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1212100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_multiply1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_Multiply_size_t.c.gcov.html b/src/test/test_Multiply_size_t.c.gcov.html new file mode 100644 index 0000000000..553b7deeae --- /dev/null +++ b/src/test/test_Multiply_size_t.c.gcov.html @@ -0,0 +1,129 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_Multiply_size_t.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_Multiply_size_t.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1212100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //-----------------------------------------------------------------------------
+       2             : // LAGraph/src/test/test_Multiply_size_t.c: test LG_Multiply_size_t
+       3             : //-----------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //-----------------------------------------------------------------------------
+      17             : 
+      18             : #include "LAGraph_test.h"
+      19             : #include "LG_internal.h"
+      20             : 
+      21             : //-----------------------------------------------------------------------------
+      22             : // test_multiply
+      23             : //-----------------------------------------------------------------------------
+      24             : 
+      25           1 : void test_multiply (void)
+      26             : {
+      27             :     char msg [LAGRAPH_MSG_LEN] ;
+      28           1 :     OK (LAGraph_Init (msg)) ;
+      29             : 
+      30           1 :     size_t c = 99 ;
+      31           1 :     TEST_CHECK (LG_Multiply_size_t (&c, (size_t) 0, (size_t) 42)) ;
+      32           1 :     TEST_CHECK (c == 0) ;
+      33             : 
+      34           1 :     TEST_CHECK (LG_Multiply_size_t (&c, (size_t) 77, (size_t) 42)) ;
+      35           1 :     TEST_CHECK (c == 77 * 42) ;
+      36             : 
+      37           1 :     TEST_CHECK (!LG_Multiply_size_t (&c, (size_t) SIZE_MAX, (size_t) 42)) ;
+      38             : 
+      39           1 :     size_t a = SIZE_MAX / 2 ;
+      40           1 :     TEST_CHECK (!LG_Multiply_size_t (&c, a, a)) ;
+      41             : 
+      42           1 :     OK (LAGraph_Finalize (msg)) ;
+      43           1 : }
+      44             : 
+      45             : //-----------------------------------------------------------------------------
+      46             : // TEST_LIST: the list of tasks for this entire test
+      47             : //-----------------------------------------------------------------------------
+      48             : 
+      49             : TEST_LIST = {
+      50             :     {"test_multiply", test_multiply},
+      51             :     // no brutal test needed
+      52             :     {NULL, NULL}
+      53             : };
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_New.c.func-sort-c.html b/src/test/test_New.c.func-sort-c.html new file mode 100644 index 0000000000..642c90602e --- /dev/null +++ b/src/test/test_New.c.func-sort-c.html @@ -0,0 +1,92 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_New.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_New.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:6767100.0 %
Date:2024-08-29 20:08:04Functions:55100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_New1
test_New_brutal1
test_New_failures1
setup2
teardown2
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_New.c.func.html b/src/test/test_New.c.func.html new file mode 100644 index 0000000000..1535f074e3 --- /dev/null +++ b/src/test/test_New.c.func.html @@ -0,0 +1,92 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_New.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_New.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:6767100.0 %
Date:2024-08-29 20:08:04Functions:55100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
setup2
teardown2
test_New1
test_New_brutal1
test_New_failures1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_New.c.gcov.html b/src/test/test_New.c.gcov.html new file mode 100644 index 0000000000..a2457075da --- /dev/null +++ b/src/test/test_New.c.gcov.html @@ -0,0 +1,265 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_New.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_New.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:6767100.0 %
Date:2024-08-29 20:08:04Functions:55100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph/src/test/test_New.c:  test LAGraph_New and LAGraph_Delete
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include "LAGraph_test.h"
+      19             : 
+      20             : //------------------------------------------------------------------------------
+      21             : // global variables
+      22             : //------------------------------------------------------------------------------
+      23             : 
+      24             : LAGraph_Graph G = NULL ;
+      25             : char msg [LAGRAPH_MSG_LEN] ;
+      26             : GrB_Matrix A = NULL ;
+      27             : #define LEN 512
+      28             : char filename [LEN+1] ;
+      29             : 
+      30             : //------------------------------------------------------------------------------
+      31             : // setup: start a test
+      32             : //------------------------------------------------------------------------------
+      33             : 
+      34           2 : void setup (void)
+      35             : {
+      36           2 :     OK (LAGraph_Init (msg)) ;
+      37           2 : }
+      38             : 
+      39             : //------------------------------------------------------------------------------
+      40             : // teardown: finalize a test
+      41             : //------------------------------------------------------------------------------
+      42             : 
+      43           2 : void teardown (void)
+      44             : {
+      45           2 :     OK (LAGraph_Finalize (msg)) ;
+      46           2 : }
+      47             : 
+      48             : //------------------------------------------------------------------------------
+      49             : // test_New:  test LAGraph_New
+      50             : //------------------------------------------------------------------------------
+      51             : 
+      52             : typedef struct
+      53             : {
+      54             :     LAGraph_Kind kind ;
+      55             :     const char *name ;
+      56             : }
+      57             : matrix_info ;
+      58             : 
+      59             : const matrix_info files [ ] =
+      60             : {
+      61             :     LAGraph_ADJACENCY_DIRECTED,   "cover.mtx",
+      62             :     LAGraph_ADJACENCY_DIRECTED,   "ldbc-directed-example.mtx",
+      63             :     LAGraph_ADJACENCY_UNDIRECTED, "ldbc-undirected-example.mtx",
+      64             :     LAGRAPH_UNKNOWN,              ""
+      65             : } ;
+      66             : 
+      67           1 : void test_New (void)
+      68             : {
+      69           1 :     setup ( ) ;
+      70             : 
+      71           1 :     for (int k = 0 ; ; k++)
+      72           3 :     {
+      73             : 
+      74             :         // load the adjacency matrix as A
+      75           4 :         const char *aname = files [k].name ;
+      76           4 :         LAGraph_Kind kind = files [k].kind ;
+      77           4 :         if (strlen (aname) == 0) break;
+      78           3 :         TEST_CASE (aname) ;
+      79           3 :         snprintf (filename, LEN, LG_DATA_DIR "%s", aname) ;
+      80           3 :         FILE *f = fopen (filename, "r") ;
+      81           3 :         TEST_CHECK (f != NULL) ;
+      82           3 :         OK (LAGraph_MMRead (&A, f, msg)) ;
+      83           3 :         OK (fclose (f)) ;
+      84           3 :         TEST_MSG ("Loading of adjacency matrix failed") ;
+      85             : 
+      86             :         // create the graph
+      87           3 :         OK (LAGraph_New (&G, &A, kind, msg)) ;
+      88           3 :         TEST_CHECK (A == NULL) ;    // A has been moved into G->A
+      89             : 
+      90             :         // check the graph
+      91           3 :         OK (LAGraph_CheckGraph (G, msg)) ;
+      92           3 :         TEST_CHECK (G->kind == kind) ;
+      93           3 :         if (kind == LAGraph_ADJACENCY_DIRECTED)
+      94             :         {
+      95           2 :             TEST_CHECK (G->is_symmetric_structure == LAGRAPH_UNKNOWN) ;
+      96             :         }
+      97             :         else
+      98             :         {
+      99           1 :             TEST_CHECK (G->is_symmetric_structure == LAGraph_TRUE) ;
+     100             :         }
+     101             : 
+     102             :         // free the graph
+     103           3 :         OK (LAGraph_Delete (&G, msg)) ;
+     104           3 :         TEST_CHECK (G == NULL) ;
+     105             :     }
+     106           1 :     teardown ( ) ;
+     107           1 : }
+     108             : 
+     109             : //------------------------------------------------------------------------------
+     110             : // test_New_brutal
+     111             : //------------------------------------------------------------------------------
+     112             : 
+     113             : #if LAGRAPH_SUITESPARSE
+     114           1 : void test_New_brutal (void)
+     115             : {
+     116           1 :     OK (LG_brutal_setup (msg)) ;
+     117           1 :     printf ("\n") ;
+     118             : 
+     119           1 :     for (int k = 0 ; ; k++)
+     120           3 :     {
+     121             : 
+     122             :         // load the adjacency matrix as A
+     123           4 :         const char *aname = files [k].name ;
+     124           4 :         LAGraph_Kind kind = files [k].kind ;
+     125           4 :         if (strlen (aname) == 0) break;
+     126           3 :         TEST_CASE (aname) ;
+     127           3 :         snprintf (filename, LEN, LG_DATA_DIR "%s", aname) ;
+     128           3 :         FILE *f = fopen (filename, "r") ;
+     129           3 :         TEST_CHECK (f != NULL) ;
+     130           3 :         OK (LAGraph_MMRead (&A, f, msg)) ;
+     131           3 :         OK (fclose (f)) ;
+     132           3 :         TEST_MSG ("Loading of adjacency matrix failed") ;
+     133             : 
+     134             :         // create the graph
+     135           6 :         LG_BRUTAL_BURBLE (LAGraph_New (&G, &A, kind, msg)) ;
+     136           3 :         TEST_CHECK (A == NULL) ;    // A has been moved into G->A
+     137             : 
+     138             :         // check the graph
+     139           3 :         LG_BRUTAL_BURBLE (LAGraph_CheckGraph (G, msg)) ;
+     140             : 
+     141             :         // free the graph
+     142           3 :         LG_BRUTAL_BURBLE (LAGraph_Delete (&G, msg)) ;
+     143           3 :         TEST_CHECK (G == NULL) ;
+     144             :     }
+     145             : 
+     146           1 :     OK (LG_brutal_teardown (msg)) ;
+     147           1 : }
+     148             : #endif
+     149             : 
+     150             : //------------------------------------------------------------------------------
+     151             : // test_New_failures:  test error handling of LAGraph_New
+     152             : //------------------------------------------------------------------------------
+     153             : 
+     154           1 : void test_New_failures (void)
+     155             : {
+     156           1 :     setup ( ) ;
+     157             : 
+     158             :     // G cannot be NULL
+     159           1 :     TEST_CHECK (LAGraph_New (NULL, NULL, 0, msg) == GrB_NULL_POINTER) ;
+     160           1 :     printf ("\nmsg: %s\n", msg) ;
+     161             : 
+     162             :     // create a graph with no adjacency matrix; this is OK, since the intent is
+     163             :     // to create a graph for which the adjacency matrix can be defined later,
+     164             :     // via assigning it to G->A.  However, the graph will be declared invalid
+     165             :     // by LAGraph_CheckGraph since G->A is NULL.
+     166           1 :     OK (LAGraph_New (&G, NULL, 0, msg)) ;
+     167           1 :     TEST_CHECK (LAGraph_CheckGraph (G, msg) == LAGRAPH_INVALID_GRAPH) ;
+     168           1 :     printf ("msg: %s\n", msg) ;
+     169           1 :     OK (LAGraph_Delete (&G, msg)) ;
+     170           1 :     TEST_CHECK (G == NULL) ;
+     171           1 :     OK (LAGraph_Delete (&G, msg)) ;
+     172           1 :     TEST_CHECK (G == NULL) ;
+     173           1 :     OK (LAGraph_Delete (NULL, msg)) ;
+     174           1 :     teardown ( ) ;
+     175           1 : }
+     176             : 
+     177             : //-----------------------------------------------------------------------------
+     178             : // TEST_LIST: the list of tasks for this entire test
+     179             : //-----------------------------------------------------------------------------
+     180             : 
+     181             : TEST_LIST =
+     182             : {
+     183             :     { "New", test_New },
+     184             :     { "New_failures", test_New_failures },
+     185             :     #if LAGRAPH_SUITESPARSE
+     186             :     { "New_brutal", test_New_brutal },
+     187             :     #endif
+     188             :     { NULL, NULL }
+     189             : } ;
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_NumThreads.c.func-sort-c.html b/src/test/test_NumThreads.c.func-sort-c.html new file mode 100644 index 0000000000..fb84481c52 --- /dev/null +++ b/src/test/test_NumThreads.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_NumThreads.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_NumThreads.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:2828100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_NumThreads1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_NumThreads.c.func.html b/src/test/test_NumThreads.c.func.html new file mode 100644 index 0000000000..888ffd1a4b --- /dev/null +++ b/src/test/test_NumThreads.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_NumThreads.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_NumThreads.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:2828100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_NumThreads1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_NumThreads.c.gcov.html b/src/test/test_NumThreads.c.gcov.html new file mode 100644 index 0000000000..73c3c705d0 --- /dev/null +++ b/src/test/test_NumThreads.c.gcov.html @@ -0,0 +1,153 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_NumThreads.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_NumThreads.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:2828100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph/src/test/test_NumThreads.c:  test LAGraph_(Get,Set)NumThreads
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include "LAGraph_test.h"
+      19             : 
+      20             : //------------------------------------------------------------------------------
+      21             : // global variables
+      22             : //------------------------------------------------------------------------------
+      23             : 
+      24             : int nthreads_outer = 0, nthreads_inner = 0 ;
+      25             : char msg [LAGRAPH_MSG_LEN] ;
+      26             : 
+      27             : //------------------------------------------------------------------------------
+      28             : // test_NumThreads:  test LAGraph_GetNumThreads and LAGraph_SetNumThreads
+      29             : //------------------------------------------------------------------------------
+      30             : 
+      31           1 : void test_NumThreads (void)
+      32             : {
+      33             : 
+      34           1 :     OK (LAGraph_Init (msg)) ;
+      35             : 
+      36           1 :     nthreads_outer = 0 ;
+      37           1 :     nthreads_inner = 0 ;
+      38           1 :     OK (LAGraph_GetNumThreads (&nthreads_outer, &nthreads_inner, msg)) ;
+      39           1 :     TEST_CHECK (nthreads_outer > 0) ;
+      40           1 :     TEST_CHECK (nthreads_inner > 0) ;
+      41             : 
+      42           1 :     nthreads_outer = 0 ;
+      43           1 :     nthreads_inner = 0 ;
+      44           1 :     OK (LAGraph_GetNumThreads (&nthreads_outer, &nthreads_inner, NULL)) ;
+      45           1 :     TEST_CHECK (nthreads_outer > 0) ;
+      46           1 :     TEST_CHECK (nthreads_inner > 0) ;
+      47             : 
+      48           1 :     OK (LAGraph_SetNumThreads (2, 4, msg)) ;
+      49           1 :     nthreads_outer = 0 ;
+      50           1 :     nthreads_inner = 0 ;
+      51           1 :     OK (LAGraph_GetNumThreads (&nthreads_outer, &nthreads_inner, msg)) ;
+      52           1 :     TEST_CHECK (nthreads_outer > 0) ;
+      53           1 :     TEST_CHECK (nthreads_inner > 0) ;
+      54             : 
+      55           1 :     OK (LAGraph_SetNumThreads (2, 4, NULL)) ;
+      56           1 :     nthreads_outer = 0 ;
+      57           1 :     nthreads_inner = 0 ;
+      58           1 :     OK (LAGraph_GetNumThreads (&nthreads_outer, &nthreads_inner, NULL)) ;
+      59           1 :     TEST_CHECK (nthreads_outer > 0) ;
+      60           1 :     TEST_CHECK (nthreads_inner > 0) ;
+      61             : 
+      62           1 :     TEST_CHECK (LAGraph_GetNumThreads (NULL, NULL, msg) == GrB_NULL_POINTER) ;
+      63           1 :     printf ("\nmsg: %s\n", msg) ;
+      64             : 
+      65           1 :     OK (LAGraph_Finalize (msg)) ;
+      66           1 : }
+      67             : 
+      68             : //-----------------------------------------------------------------------------
+      69             : // TEST_LIST: the list of tasks for this entire test
+      70             : //-----------------------------------------------------------------------------
+      71             : 
+      72             : TEST_LIST =
+      73             : {
+      74             :     { "NumThreads", test_NumThreads },
+      75             :     // no brutal test needed
+      76             :     { NULL, NULL }
+      77             : } ;
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_PageRank.c.func-sort-c.html b/src/test/test_PageRank.c.func-sort-c.html new file mode 100644 index 0000000000..5e8309eaf8 --- /dev/null +++ b/src/test/test_PageRank.c.func-sort-c.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_PageRank.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_PageRank.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:9797100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_ranker1
difference6
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_PageRank.c.func.html b/src/test/test_PageRank.c.func.html new file mode 100644 index 0000000000..7a58a5fcc5 --- /dev/null +++ b/src/test/test_PageRank.c.func.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_PageRank.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_PageRank.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:9797100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
difference6
test_ranker1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_PageRank.c.gcov.html b/src/test/test_PageRank.c.gcov.html new file mode 100644 index 0000000000..c6fea2b28b --- /dev/null +++ b/src/test/test_PageRank.c.gcov.html @@ -0,0 +1,415 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_PageRank.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_PageRank.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:9797100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph/src/test/test_PageRank.c: test cases for pagerank
+       3             : // -----------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include <stdio.h>
+      19             : #include <acutest.h>
+      20             : 
+      21             : #include <LAGraph_test.h>
+      22             : 
+      23             : #define LEN 512
+      24             : char msg [LAGRAPH_MSG_LEN] ;
+      25             : char filename [LEN+1] ;
+      26             : LAGraph_Graph G = NULL ;
+      27             : 
+      28             : //------------------------------------------------------------------------------
+      29             : // difference: compare the LAGraph and MATLAB results
+      30             : //------------------------------------------------------------------------------
+      31             : 
+      32             : float difference (GrB_Vector centrality, double *matlab_result) ;
+      33             : 
+      34           6 : float difference (GrB_Vector centrality, double *matlab_result)
+      35             : {
+      36           6 :     GrB_Vector diff = NULL, cmatlab = NULL ;
+      37           6 :     GrB_Index n = 0 ;
+      38           6 :     OK (GrB_Vector_size (&n, centrality)) ;
+      39           6 :     OK (GrB_Vector_new (&cmatlab, GrB_FP32, n)) ;
+      40         228 :     for (int i = 0 ; i < n ; i++)
+      41             :     {
+      42         222 :         OK (GrB_Vector_setElement_FP64 (cmatlab, matlab_result [i], i)) ;
+      43             :     }
+      44             :     // diff = max (abs (cmatlab - centrality))
+      45           6 :     OK (GrB_Vector_new (&diff, GrB_FP32, n)) ;
+      46           6 :     OK (GrB_eWiseAdd (diff, NULL, NULL, GrB_MINUS_FP32, cmatlab, centrality,
+      47             :         NULL)) ;
+      48           6 :     OK (GrB_apply (diff, NULL, NULL, GrB_ABS_FP32, diff, NULL)) ;
+      49           6 :     float err = 0 ;
+      50           6 :     OK (GrB_reduce (&err, NULL, GrB_MAX_MONOID_FP32, diff, NULL)) ;
+      51           6 :     OK (GrB_free (&diff)) ;
+      52           6 :     OK (GrB_free (&cmatlab)) ;
+      53           6 :     return (err) ;
+      54             : }
+      55             : 
+      56             : //------------------------------------------------------------------------------
+      57             : // valid results for karate graph and west0067 graphs
+      58             : //------------------------------------------------------------------------------
+      59             : 
+      60             : // The first two matrices have no sinks (nodes with zero outdegree) so the
+      61             : // MATLAB centrality (G, 'pagerank'), LAGraph_VertextCentrality_PageRankGAP,
+      62             : // and LAGr_PageRank results will be essentially the same.
+      63             : 
+      64             : // MATLAB computes in double precision, while LAGraph_*PageRank* computes in
+      65             : // single precision, so the difference will be about 1e-5 or so.
+      66             : 
+      67             : double karate_rank [34] = {
+      68             :     0.0970011147,
+      69             :     0.0528720584,
+      70             :     0.0570750515,
+      71             :     0.0358615175,
+      72             :     0.0219857202,
+      73             :     0.0291233505,
+      74             :     0.0291233505,
+      75             :     0.0244945048,
+      76             :     0.0297681451,
+      77             :     0.0143104668,
+      78             :     0.0219857202,
+      79             :     0.0095668739,
+      80             :     0.0146475355,
+      81             :     0.0295415677,
+      82             :     0.0145381625,
+      83             :     0.0145381625,
+      84             :     0.0167900065,
+      85             :     0.0145622041,
+      86             :     0.0145381625,
+      87             :     0.0196092670,
+      88             :     0.0145381625,
+      89             :     0.0145622041,
+      90             :     0.0145381625,
+      91             :     0.0315206825,
+      92             :     0.0210719482,
+      93             :     0.0210013837,
+      94             :     0.0150430281,
+      95             :     0.0256382216,
+      96             :     0.0195723309,
+      97             :     0.0262863139,
+      98             :     0.0245921424,
+      99             :     0.0371606178,
+     100             :     0.0716632142,
+     101             :     0.1008786453 } ;
+     102             : 
+     103             : double west0067_rank [67] = {
+     104             :     0.0233753869,
+     105             :     0.0139102552,
+     106             :     0.0123441027,
+     107             :     0.0145657095,
+     108             :     0.0142018541,
+     109             :     0.0100791606,
+     110             :     0.0128753395,
+     111             :     0.0143945684,
+     112             :     0.0110203141,
+     113             :     0.0110525383,
+     114             :     0.0119311961,
+     115             :     0.0072382247,
+     116             :     0.0188680398,
+     117             :     0.0141596605,
+     118             :     0.0174877889,
+     119             :     0.0170362099,
+     120             :     0.0120433909,
+     121             :     0.0219844489,
+     122             :     0.0195274443,
+     123             :     0.0394465722,
+     124             :     0.0112038726,
+     125             :     0.0090174094,
+     126             :     0.0140088120,
+     127             :     0.0122532937,
+     128             :     0.0153346283,
+     129             :     0.0135241334,
+     130             :     0.0158714693,
+     131             :     0.0149689529,
+     132             :     0.0144097230,
+     133             :     0.0137583019,
+     134             :     0.0314386080,
+     135             :     0.0092857745,
+     136             :     0.0081814168,
+     137             :     0.0102137827,
+     138             :     0.0096547214,
+     139             :     0.0129622400,
+     140             :     0.0244173417,
+     141             :     0.0173963657,
+     142             :     0.0127705717,
+     143             :     0.0143297446,
+     144             :     0.0140509341,
+     145             :     0.0104117131,
+     146             :     0.0173516407,
+     147             :     0.0149175105,
+     148             :     0.0119979624,
+     149             :     0.0095043613,
+     150             :     0.0153295328,
+     151             :     0.0077710930,
+     152             :     0.0259969472,
+     153             :     0.0126926269,
+     154             :     0.0088870166,
+     155             :     0.0080836101,
+     156             :     0.0096023576,
+     157             :     0.0091000837,
+     158             :     0.0246131958,
+     159             :     0.0159589365,
+     160             :     0.0183500031,
+     161             :     0.0155811507,
+     162             :     0.0157693756,
+     163             :     0.0116319823,
+     164             :     0.0230649292,
+     165             :     0.0149070613,
+     166             :     0.0157469640,
+     167             :     0.0134396036,
+     168             :     0.0189218603,
+     169             :     0.0114528518,
+     170             :     0.0223213267 } ;
+     171             : 
+     172             : // ldbc-directed-example.mtx has two sinks: nodes 3 and 9
+     173             : // its pagerank must be computed with LAGr_PageRank.
+     174             : double ldbc_directed_example_rank [10] = {
+     175             :     0.1697481823,
+     176             :     0.0361514465,
+     177             :     0.1673241104,
+     178             :     0.1669092572,
+     179             :     0.1540948145,
+     180             :     0.0361514465,
+     181             :     0.0361514465,
+     182             :     0.1153655134,
+     183             :     0.0361514465,
+     184             :     0.0819523364 } ;
+     185             : 
+     186             : //------------------------------------------------------------------------------
+     187             : // tesk_ranker
+     188             : //------------------------------------------------------------------------------
+     189             : 
+     190           1 : void test_ranker(void)
+     191             : {
+     192           1 :     LAGraph_Init (msg) ;
+     193           1 :     GrB_Matrix A = NULL ;
+     194           1 :     GrB_Vector centrality = NULL, cmatlab = NULL, diff = NULL ;
+     195           1 :     int niters = 0 ;
+     196             : 
+     197             :     //--------------------------------------------------------------------------
+     198             :     // karate: no sinks
+     199             :     //--------------------------------------------------------------------------
+     200             : 
+     201             :     // create the karate graph
+     202           1 :     snprintf (filename, LEN, LG_DATA_DIR "%s", "karate.mtx") ;
+     203           1 :     FILE *f = fopen (filename, "r") ;
+     204           1 :     TEST_CHECK (f != NULL) ;
+     205           1 :     OK (LAGraph_MMRead (&A, f, msg)) ;
+     206           1 :     OK (fclose (f)) ;
+     207           1 :     OK (LAGraph_New (&G, &A, LAGraph_ADJACENCY_UNDIRECTED, msg)) ;
+     208           1 :     TEST_CHECK (A == NULL) ;    // A has been moved into G->A
+     209           1 :     OK (LAGraph_Cached_OutDegree (G, msg)) ;
+     210             : 
+     211             :     // compute its pagerank using the GAP method
+     212           1 :     OK (LAGr_PageRankGAP (&centrality, &niters, G, 0.85,
+     213             :         1e-4, 100, msg)) ;
+     214             : 
+     215             :     // compare with MATLAB: cmatlab = centrality (G, 'pagerank')
+     216           1 :     float err = difference (centrality, karate_rank) ;
+     217           1 :     float rsum = 0 ;
+     218           1 :     OK (GrB_reduce (&rsum, NULL, GrB_PLUS_MONOID_FP32, centrality, NULL)) ;
+     219           1 :     printf ("\nkarate:   err: %e (GAP),      sum(r): %e iters: %d\n",
+     220             :         err, rsum, niters) ;
+     221           1 :     TEST_CHECK (err < 1e-4) ;
+     222           1 :     OK (GrB_free (&centrality)) ;
+     223             : 
+     224             :     // compute its pagerank using the standard method
+     225           1 :     OK (LAGr_PageRank (&centrality, &niters, G, 0.85, 1e-4, 100, msg)) ;
+     226             : 
+     227             :     // compare with MATLAB: cmatlab = centrality (G, 'pagerank')
+     228           1 :     err = difference (centrality, karate_rank) ;
+     229           1 :     OK (GrB_reduce (&rsum, NULL, GrB_PLUS_MONOID_FP32, centrality, NULL)) ;
+     230           1 :     printf ("karate:   err: %e (standard), sum(r): %e iters: %d\n",
+     231             :         err, rsum, niters) ;
+     232           1 :     TEST_CHECK (err < 1e-4) ;
+     233           1 :     OK (GrB_free (&centrality)) ;
+     234             : 
+     235             :     // test for failure to converge
+     236           1 :     int status = LAGr_PageRank (&centrality, &niters, G, 0.85, 1e-4, 2, msg) ;
+     237           1 :     printf ("status: %d msg: %s\n", status, msg) ;
+     238           1 :     TEST_CHECK (status == LAGRAPH_CONVERGENCE_FAILURE) ;
+     239             : 
+     240           1 :     OK (LAGraph_Delete (&G, msg)) ;
+     241             : 
+     242             :     //--------------------------------------------------------------------------
+     243             :     // west0067: no sinks
+     244             :     //--------------------------------------------------------------------------
+     245             : 
+     246             :     // create the west0067 graph
+     247           1 :     snprintf (filename, LEN, LG_DATA_DIR "%s", "west0067.mtx") ;
+     248           1 :     f = fopen (filename, "r") ;
+     249           1 :     TEST_CHECK (f != NULL) ;
+     250           1 :     OK (LAGraph_MMRead (&A, f, msg)) ;
+     251           1 :     OK (fclose (f)) ;
+     252           1 :     OK (LAGraph_New (&G, &A, LAGraph_ADJACENCY_DIRECTED, msg)) ;
+     253           1 :     TEST_CHECK (A == NULL) ;    // A has been moved into G->A
+     254           1 :     OK (LAGraph_Cached_AT (G, msg)) ;
+     255           1 :     OK (LAGraph_Cached_OutDegree (G, msg)) ;
+     256             : 
+     257             :     // compute its pagerank using the GAP method
+     258           1 :     OK (LAGr_PageRankGAP (&centrality, &niters, G, 0.85,
+     259             :         1e-4, 100, msg)) ;
+     260             : 
+     261             :     // compare with MATLAB: cmatlab = centrality (G, 'pagerank')
+     262           1 :     err = difference (centrality, west0067_rank) ;
+     263           1 :     OK (GrB_reduce (&rsum, NULL, GrB_PLUS_MONOID_FP32, centrality, NULL)) ;
+     264           1 :     printf ("west0067: err: %e (GAP),      sum(r): %e iters: %d\n",
+     265             :         err, rsum, niters) ;
+     266           1 :     TEST_CHECK (err < 1e-4) ;
+     267           1 :     OK (GrB_free (&centrality)) ;
+     268             : 
+     269             :     // compute its pagerank using the standard method
+     270           1 :     OK (LAGr_PageRank (&centrality, &niters, G, 0.85, 1e-4, 100, msg)) ;
+     271             : 
+     272             :     // compare with MATLAB: cmatlab = centrality (G, 'pagerank')
+     273           1 :     err = difference (centrality, west0067_rank) ;
+     274           1 :     printf ("west0067: err: %e (standard), sum(r): %e iters: %d\n",
+     275             :         err, rsum, niters) ;
+     276           1 :     TEST_CHECK (err < 1e-4) ;
+     277           1 :     OK (GrB_free (&centrality)) ;
+     278             : 
+     279           1 :     OK (LAGraph_Delete (&G, msg)) ;
+     280             : 
+     281             :     //--------------------------------------------------------------------------
+     282             :     // ldbc-directed-example: has 2 sinks
+     283             :     //--------------------------------------------------------------------------
+     284             : 
+     285             :     // create the ldbc-directed-example graph
+     286           1 :     snprintf (filename, LEN, LG_DATA_DIR "%s", "ldbc-directed-example.mtx") ;
+     287           1 :     f = fopen (filename, "r") ;
+     288           1 :     TEST_CHECK (f != NULL) ;
+     289           1 :     OK (LAGraph_MMRead (&A, f, msg)) ;
+     290           1 :     OK (fclose (f)) ;
+     291           1 :     OK (LAGraph_New (&G, &A, LAGraph_ADJACENCY_DIRECTED, msg)) ;
+     292           1 :     TEST_CHECK (A == NULL) ;    // A has been moved into G->A
+     293           1 :     OK (LAGraph_Cached_AT (G, msg)) ;
+     294           1 :     OK (LAGraph_Cached_OutDegree (G, msg)) ;
+     295             : 
+     296           1 :     printf ("\n=========== ldbc-directed-example, with sink nodes 3 and 9:\n") ;
+     297           1 :     OK (LAGraph_Graph_Print (G, LAGraph_COMPLETE, stdout, msg)) ;
+     298             : 
+     299             :     // compute its pagerank using the GAP method ("bleeds" rank)
+     300           1 :     OK (LAGr_PageRankGAP (&centrality, &niters, G, 0.85,
+     301             :         1e-4, 100, msg)) ;
+     302           1 :     err = difference (centrality, ldbc_directed_example_rank) ;
+     303           1 :     OK (GrB_reduce (&rsum, NULL, GrB_PLUS_MONOID_FP32, centrality, NULL)) ;
+     304           1 :     printf ("\nGAP-style page rank is expected to be wrong:\n") ;
+     305           1 :     printf ("ldbc-directed: err: %e (GAP), sum(r): %e, niters %d\n",
+     306             :         err, rsum, niters) ;
+     307           1 :     printf ("The GAP pagerank is incorrect for this method:\n") ;
+     308           1 :     OK (LAGraph_Vector_Print (centrality, LAGraph_COMPLETE, stdout, msg)) ;
+     309           1 :     OK (GrB_free (&centrality)) ;
+     310             : 
+     311             :     // compute its pagerank using the standard method
+     312           1 :     OK (LAGr_PageRank (&centrality, &niters, G, 0.85, 1e-4, 100, msg)) ;
+     313             : 
+     314             :     // compare with MATLAB: cmatlab = centrality (G, 'pagerank')
+     315           1 :     err = difference (centrality, ldbc_directed_example_rank) ;
+     316           1 :     OK (GrB_reduce (&rsum, NULL, GrB_PLUS_MONOID_FP32, centrality, NULL)) ;
+     317           1 :     printf ("\nwith sinks handled properly:\n") ;
+     318           1 :     printf ("ldbc-directed: err: %e (standard), sum(r): %e, niters %d\n",
+     319             :         err, rsum, niters) ;
+     320           1 :     TEST_CHECK (err < 1e-4) ;
+     321           1 :     printf ("This is the correct pagerank, with sinks handled properly:\n") ;
+     322           1 :     OK (LAGraph_Vector_Print (centrality, LAGraph_COMPLETE, stdout, msg)) ;
+     323           1 :     OK (GrB_free (&centrality)) ;
+     324             : 
+     325           1 :     OK (LAGraph_Delete (&G, msg)) ;
+     326             : 
+     327             :     //--------------------------------------------------------------------------
+     328             : 
+     329           1 :     LAGraph_Finalize (msg) ;
+     330           1 : }
+     331             : 
+     332             : //------------------------------------------------------------------------------
+     333             : // list of tests
+     334             : //------------------------------------------------------------------------------
+     335             : 
+     336             : TEST_LIST = {
+     337             :     {"test_ranker", test_ranker},
+     338             :     {NULL, NULL}
+     339             : };
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_SampleDegree.c.func-sort-c.html b/src/test/test_SampleDegree.c.func-sort-c.html new file mode 100644 index 0000000000..bd195693ec --- /dev/null +++ b/src/test/test_SampleDegree.c.func-sort-c.html @@ -0,0 +1,92 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_SampleDegree.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_SampleDegree.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:8181100.0 %
Date:2024-08-29 20:08:04Functions:55100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
setup1
teardown1
test_SampleDegree1
test_SampleDegree_brutal1
is_close72
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_SampleDegree.c.func.html b/src/test/test_SampleDegree.c.func.html new file mode 100644 index 0000000000..7f7023ab45 --- /dev/null +++ b/src/test/test_SampleDegree.c.func.html @@ -0,0 +1,92 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_SampleDegree.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_SampleDegree.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:8181100.0 %
Date:2024-08-29 20:08:04Functions:55100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
is_close72
setup1
teardown1
test_SampleDegree1
test_SampleDegree_brutal1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_SampleDegree.c.gcov.html b/src/test/test_SampleDegree.c.gcov.html new file mode 100644 index 0000000000..a1bc8b4ad6 --- /dev/null +++ b/src/test/test_SampleDegree.c.gcov.html @@ -0,0 +1,334 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_SampleDegree.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_SampleDegree.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:8181100.0 %
Date:2024-08-29 20:08:04Functions:55100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph/src/test/test_SampleDegree.c:  test LAGr_SampleDegree
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include "LAGraph_test.h"
+      19             : 
+      20             : //------------------------------------------------------------------------------
+      21             : // global variables
+      22             : //------------------------------------------------------------------------------
+      23             : 
+      24             : LAGraph_Graph G = NULL ;
+      25             : char msg [LAGRAPH_MSG_LEN] ;
+      26             : GrB_Matrix A = NULL ;
+      27             : double mean, median ;
+      28             : int ret_code ;
+      29             : #define LEN 512
+      30             : char filename [LEN+1] ;
+      31             : 
+      32             : //------------------------------------------------------------------------------
+      33             : // setup: start a test
+      34             : //------------------------------------------------------------------------------
+      35             : 
+      36           1 : void setup (void)
+      37             : {
+      38           1 :     OK (LAGraph_Init (msg)) ;
+      39           1 : }
+      40             : 
+      41             : //------------------------------------------------------------------------------
+      42             : // teardown: finalize a test
+      43             : //------------------------------------------------------------------------------
+      44             : 
+      45           1 : void teardown (void)
+      46             : {
+      47           1 :     OK (LAGraph_Finalize (msg)) ;
+      48           1 : }
+      49             : 
+      50             : //------------------------------------------------------------------------------
+      51             : // is_close: check whether two floats are close
+      52             : //------------------------------------------------------------------------------
+      53             : 
+      54          72 : bool is_close (double a, double b)
+      55             : {
+      56          72 :     double abs_diff = fabs(a - b) ;
+      57          72 :     return abs_diff < 1e-6 ;
+      58             : }
+      59             : 
+      60             : //------------------------------------------------------------------------------
+      61             : // test_SampleDegree:  test LAGr_SampleDegree
+      62             : //------------------------------------------------------------------------------
+      63             : 
+      64             : typedef struct
+      65             : {
+      66             :     const char *name ;
+      67             :     const double row_mean ;
+      68             :     const double row_median ;
+      69             :     const double col_mean ;
+      70             :     const double col_median ;
+      71             :     const int64_t nsamples ;
+      72             :     const uint64_t seed ;
+      73             : }
+      74             : matrix_info ;
+      75             : 
+      76             : const matrix_info files [ ] =
+      77             : {
+      78             :     { "A.mtx",
+      79             :         4.6, 5.0,
+      80             :         4.6, 5.0,
+      81             :         5, 123456 },
+      82             :      { "LFAT5.mtx",
+      83             :         2.2, 2.0,
+      84             :         2.2, 2.0,
+      85             :         5, 123456 },
+      86             :      { "cover.mtx",
+      87             :         1.4, 1.0,
+      88             :         2.4, 3.0,
+      89             :         5, 123456 },
+      90             :      { "full.mtx",
+      91             :         3.0, 3.0,
+      92             :         3.0, 3.0,
+      93             :         5, 123456 },
+      94             :      { "full_symmetric.mtx",
+      95             :         4.0, 4.0,
+      96             :         4.0, 4.0,
+      97             :         5, 123456 },
+      98             :      { "karate.mtx",
+      99             :         3.0, 3.0,
+     100             :         3.0, 3.0,
+     101             :         5, 123456 },
+     102             :      // Add karate two more times to test seed and nsamples
+     103             :      { "karate.mtx",
+     104             :         3.46666666667, 3.0,
+     105             :         3.46666666667, 3.0,
+     106             :         15, 123456 },
+     107             :      { "karate.mtx",
+     108             :         8.4, 6.0,
+     109             :         8.4, 6.0,
+     110             :         5, 87654432 },
+     111             :      { "ldbc-cdlp-directed-example.mtx",
+     112             :         2.2, 2.0,
+     113             :         1.8, 2.0,
+     114             :         5, 123456 },
+     115             : //   { "ldbc-directed-example-bool.mtx",
+     116             : //      2.5, 3.0,
+     117             : //      3.8, 3.0,
+     118             : //      10, 123456 },
+     119             :     { "", 0.0, 0.0, 0.0, 0.0, 1, 0 }
+     120             : } ;
+     121             : 
+     122             : //-----------------------------------------------------------------------------
+     123             : // test_SampleDegree
+     124             : //-----------------------------------------------------------------------------
+     125             : 
+     126           1 : void test_SampleDegree (void)
+     127             : {
+     128           1 :     setup ( ) ;
+     129             : 
+     130           1 :     for (int k = 0 ; ; k++)
+     131           9 :     {
+     132             : 
+     133             :         // load the matrix as A
+     134          10 :         const char *aname = files [k].name ;
+     135          10 :         if (strlen (aname) == 0) break;
+     136           9 :         TEST_CASE (aname) ;
+     137           9 :         printf ("\n==================== Test case: %s\n", aname) ;
+     138           9 :         snprintf (filename, LEN, LG_DATA_DIR "%s", aname) ;
+     139           9 :         FILE *f = fopen (filename, "r") ;
+     140           9 :         TEST_CHECK (f != NULL) ;
+     141           9 :         OK (LAGraph_MMRead (&A, f, msg)) ;
+     142           9 :         OK (fclose (f)) ;
+     143           9 :         TEST_MSG ("Loading of adjacency matrix failed") ;
+     144             : 
+     145             :         // construct the graph G with adjacency matrix A
+     146           9 :         OK (LAGraph_New (&G, &A, LAGraph_ADJACENCY_DIRECTED, msg)) ;
+     147           9 :         TEST_CHECK (A == NULL) ;
+     148             : 
+     149             :         // SampleDegree requires degrees to be precomputed
+     150          18 :         ret_code = LAGr_SampleDegree (&mean, &median, G, 1,
+     151           9 :             files [k].nsamples, files [k].seed, msg) ;
+     152           9 :         TEST_CHECK (ret_code == LAGRAPH_NOT_CACHED) ;
+     153           9 :         TEST_MSG ("SampleDegree without row degrees precomputed succeeded") ;
+     154             : 
+     155          18 :         ret_code = LAGr_SampleDegree (&mean, &median, G, 0,
+     156           9 :             files [k].nsamples, files [k].seed, msg) ;
+     157           9 :         TEST_CHECK (ret_code == LAGRAPH_NOT_CACHED) ;
+     158           9 :         TEST_MSG ("SampleDegree without column degrees precomputed succeeded") ;
+     159             : 
+     160             :         // Compute and check the row samples
+     161           9 :         OK (LAGraph_Cached_OutDegree (G, msg)) ;
+     162           9 :         OK (LAGr_SampleDegree (&mean, &median, G, 1,
+     163             :             files [k].nsamples, files [k].seed, msg)) ;
+     164             : 
+     165           9 :         TEST_CHECK (is_close(mean, files [k].row_mean)) ;
+     166           9 :         TEST_MSG ("Row Mean Expected: %f", files [k].row_mean) ;
+     167           9 :         TEST_MSG ("Row Mean Produced: %f", mean) ;
+     168             : 
+     169           9 :         TEST_CHECK (is_close(median, files [k].row_median)) ;
+     170           9 :         TEST_MSG ("Row Median Expected: %f", files [k].row_median) ;
+     171           9 :         TEST_MSG ("Row Median Produced: %f", median) ;
+     172             : 
+     173             :         // Compute the column samples
+     174           9 :         OK (LAGraph_DeleteCached (G, msg)) ;
+     175             : 
+     176           9 :         OK (LAGraph_Cached_InDegree (G, msg)) ;
+     177           9 :         OK (LAGr_SampleDegree (&mean, &median, G, 0,
+     178             :             files [k].nsamples, files [k].seed, msg)) ;
+     179             : 
+     180           9 :         TEST_CHECK (is_close(mean, files [k].col_mean)) ;
+     181           9 :         TEST_MSG ("Column Mean Expected: %f", files [k].col_mean) ;
+     182           9 :         TEST_MSG ("Column Mean Produced: %f", mean) ;
+     183             : 
+     184           9 :         TEST_CHECK (is_close(median, files [k].col_median)) ;
+     185           9 :         TEST_MSG ("Column Median Expected: %f", files [k].col_median) ;
+     186           9 :         TEST_MSG ("Column Median Produced: %f", median) ;
+     187             : 
+     188           9 :         OK (LAGraph_Delete (&G, msg)) ;
+     189             :     }
+     190             : 
+     191           1 :     teardown ( ) ;
+     192           1 : }
+     193             : 
+     194             : //-----------------------------------------------------------------------------
+     195             : // test_SampleDegree_brutal
+     196             : //-----------------------------------------------------------------------------
+     197             : 
+     198             : #if LAGRAPH_SUITESPARSE
+     199           1 : void test_SampleDegree_brutal (void)
+     200             : {
+     201           1 :     OK (LG_brutal_setup (msg)) ;
+     202             : 
+     203           1 :     for (int k = 0 ; ; k++)
+     204           9 :     {
+     205             : 
+     206             :         // load the matrix as A
+     207          10 :         const char *aname = files [k].name ;
+     208          10 :         if (strlen (aname) == 0) break;
+     209           9 :         TEST_CASE (aname) ;
+     210           9 :         printf ("\n==================== Test case: %s\n", aname) ;
+     211           9 :         snprintf (filename, LEN, LG_DATA_DIR "%s", aname) ;
+     212           9 :         FILE *f = fopen (filename, "r") ;
+     213           9 :         TEST_CHECK (f != NULL) ;
+     214           9 :         OK (LAGraph_MMRead (&A, f, msg)) ;
+     215           9 :         OK (fclose (f)) ;
+     216           9 :         TEST_MSG ("Loading of adjacency matrix failed") ;
+     217             : 
+     218             :         // construct the graph G with adjacency matrix A
+     219           9 :         OK (LAGraph_New (&G, &A, LAGraph_ADJACENCY_DIRECTED, msg)) ;
+     220           9 :         TEST_CHECK (A == NULL) ;
+     221             : 
+     222             :         // Compute and check the row samples
+     223          67 :         LG_BRUTAL (LAGraph_Cached_OutDegree (G, msg)) ;
+     224          18 :         LG_BRUTAL (LAGr_SampleDegree (&mean, &median, G, 1,
+     225             :             files [k].nsamples, files [k].seed, msg)) ;
+     226             : 
+     227           9 :         TEST_CHECK (is_close(mean, files [k].row_mean)) ;
+     228           9 :         TEST_CHECK (is_close(median, files [k].row_median)) ;
+     229             : 
+     230             :         // Compute the column samples
+     231           9 :         LG_BRUTAL (LAGraph_DeleteCached (G, msg)) ;
+     232             : 
+     233          78 :         LG_BRUTAL (LAGraph_Cached_InDegree (G, msg)) ;
+     234          18 :         LG_BRUTAL (LAGr_SampleDegree (&mean, &median, G, 0,
+     235             :             files [k].nsamples, files [k].seed, msg)) ;
+     236             : 
+     237           9 :         TEST_CHECK (is_close(mean, files [k].col_mean)) ;
+     238           9 :         TEST_CHECK (is_close(median, files [k].col_median)) ;
+     239             : 
+     240           9 :         OK (LAGraph_Delete (&G, msg)) ;
+     241             :     }
+     242             : 
+     243           1 :     OK (LG_brutal_teardown (msg)) ;
+     244           1 : }
+     245             : #endif
+     246             : 
+     247             : //-----------------------------------------------------------------------------
+     248             : // TEST_LIST: the list of tasks for this entire test
+     249             : //-----------------------------------------------------------------------------
+     250             : 
+     251             : TEST_LIST =
+     252             : {
+     253             :     { "SampleDegree", test_SampleDegree },
+     254             :     #if LAGRAPH_SUITESPARSE
+     255             :     { "SampleDegree_brutal", test_SampleDegree_brutal },
+     256             :     #endif
+     257             :     { NULL, NULL }
+     258             : } ;
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_SingleSourceShortestPath.c.func-sort-c.html b/src/test/test_SingleSourceShortestPath.c.func-sort-c.html new file mode 100644 index 0000000000..c22ac2c301 --- /dev/null +++ b/src/test/test_SingleSourceShortestPath.c.func-sort-c.html @@ -0,0 +1,88 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_SingleSourceShortestPath.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_SingleSourceShortestPath.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:225225100.0 %
Date:2024-08-29 20:08:04Functions:44100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_SingleSourceShortestPath1
test_SingleSourceShortestPath_brutal1
test_SingleSourceShortestPath_failure1
test_SingleSourceShortestPath_types1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_SingleSourceShortestPath.c.func.html b/src/test/test_SingleSourceShortestPath.c.func.html new file mode 100644 index 0000000000..6a191430f3 --- /dev/null +++ b/src/test/test_SingleSourceShortestPath.c.func.html @@ -0,0 +1,88 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_SingleSourceShortestPath.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_SingleSourceShortestPath.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:225225100.0 %
Date:2024-08-29 20:08:04Functions:44100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_SingleSourceShortestPath1
test_SingleSourceShortestPath_brutal1
test_SingleSourceShortestPath_failure1
test_SingleSourceShortestPath_types1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_SingleSourceShortestPath.c.gcov.html b/src/test/test_SingleSourceShortestPath.c.gcov.html new file mode 100644 index 0000000000..e241fabb4c --- /dev/null +++ b/src/test/test_SingleSourceShortestPath.c.gcov.html @@ -0,0 +1,532 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_SingleSourceShortestPath.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_SingleSourceShortestPath.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:225225100.0 %
Date:2024-08-29 20:08:04Functions:44100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //----------------------------------------------------------------------------
+       2             : // LAGraph/src/test/test_SingleSourceShortestPath.c: test cases for SSSP
+       3             : // ----------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //-----------------------------------------------------------------------------
+      17             : 
+      18             : #include <stdio.h>
+      19             : #include <acutest.h>
+      20             : #include <LAGraph_test.h>
+      21             : #include "LG_internal.h"
+      22             : 
+      23             : char msg [LAGRAPH_MSG_LEN] ;
+      24             : LAGraph_Graph G = NULL ;
+      25             : 
+      26             : #define LEN 512
+      27             : char filename [LEN+1] ;
+      28             : char atype_name [LAGRAPH_MAX_NAME_LEN] ;
+      29             : 
+      30             : typedef struct
+      31             : {
+      32             :     const char *name ;
+      33             : }
+      34             : matrix_info ;
+      35             : 
+      36             : const matrix_info files [ ] =
+      37             : {
+      38             :     { "A.mtx" },
+      39             :     { "cover.mtx" },
+      40             :     { "jagmesh7.mtx" },
+      41             :     { "ldbc-cdlp-directed-example.mtx" },
+      42             :     { "ldbc-cdlp-undirected-example.mtx" },
+      43             :     { "ldbc-directed-example.mtx" },
+      44             :     { "ldbc-undirected-example.mtx" },
+      45             :     { "ldbc-wcc-example.mtx" },
+      46             :     { "LFAT5.mtx" },
+      47             :     { "LFAT5_hypersparse.mtx" },
+      48             :     { "msf1.mtx" },
+      49             :     { "msf2.mtx" },
+      50             :     { "msf3.mtx" },
+      51             :     { "sample2.mtx" },
+      52             :     { "sample.mtx" },
+      53             :     { "olm1000.mtx" },
+      54             :     { "bcsstk13.mtx" },
+      55             :     { "cryg2500.mtx" },
+      56             :     { "tree-example.mtx" },
+      57             :     { "west0067.mtx" },
+      58             :     { "karate.mtx" },
+      59             :     { "matrix_bool.mtx" },
+      60             :     { "test_BF.mtx" },
+      61             :     { "test_FW_1000.mtx" },
+      62             :     { "test_FW_2003.mtx" },
+      63             :     { "test_FW_2500.mtx" },
+      64             :     { "skew_fp32.mtx" },
+      65             :     { "matrix_uint32.mtx" },
+      66             :     { "matrix_uint64.mtx" },
+      67             :     { "" },
+      68             : } ;
+      69             : 
+      70             : //****************************************************************************
+      71           1 : void test_SingleSourceShortestPath(void)
+      72             : {
+      73           1 :     LAGraph_Init(msg);
+      74           1 :     GrB_Matrix A = NULL, T = NULL ;
+      75           1 :     GrB_Scalar Delta = NULL ;
+      76           1 :     OK (GrB_Scalar_new (&Delta, GrB_INT32)) ;
+      77             : 
+      78           1 :     for (int k = 0 ; ; k++)
+      79          29 :     {
+      80             : 
+      81             :         // load the adjacency matrix as A
+      82          30 :         const char *aname = files [k].name ;
+      83          30 :         LAGraph_Kind kind = LAGraph_ADJACENCY_DIRECTED ;
+      84             :         // LAGraph_Kind kind = files [k].kind ;
+      85          30 :         if (strlen (aname) == 0) break;
+      86          29 :         TEST_CASE (aname) ;
+      87          29 :         printf ("\nMatrix: %s\n", aname) ;
+      88          29 :         snprintf (filename, LEN, LG_DATA_DIR "%s", aname) ;
+      89          29 :         FILE *f = fopen (filename, "r") ;
+      90          29 :         TEST_CHECK (f != NULL) ;
+      91          29 :         OK (LAGraph_MMRead (&A, f, msg)) ;
+      92          29 :         OK (fclose (f)) ;
+      93          29 :         TEST_MSG ("Loading of adjacency matrix failed") ;
+      94             : 
+      95          29 :         GrB_Index n = 0, ncols = 1 ;
+      96          29 :         OK (GrB_Matrix_nrows (&n, A)) ;
+      97          29 :         OK (GrB_Matrix_ncols (&ncols, A)) ;
+      98          29 :         TEST_CHECK (n == ncols) ;
+      99             : 
+     100             :         // convert A to int32
+     101          29 :         OK (LAGraph_Matrix_TypeName (atype_name, A, msg)) ;
+     102          29 :         if (!MATCHNAME (atype_name, "int32_t"))
+     103             :         {
+     104          28 :             OK (GrB_Matrix_new (&T, GrB_INT32, n, n)) ;
+     105          28 :             OK (GrB_assign (T, NULL, NULL, A, GrB_ALL, n, GrB_ALL, n, NULL)) ;
+     106          28 :             OK (GrB_free (&A)) ;
+     107          28 :             A = T ;
+     108             :         }
+     109             : 
+     110             :         // ensure all entries are positive, and in the range 1 to 255
+     111          29 :         OK (GrB_Matrix_apply_BinaryOp2nd_INT32 (A, NULL, NULL,
+     112             :             GrB_BAND_INT32, A, 255, NULL)) ;
+     113             :         int32_t x ;
+     114          29 :         OK (GrB_reduce (&x, NULL, GrB_MIN_MONOID_INT32, A, NULL)) ;
+     115          29 :         if (x < 1)
+     116             :         {
+     117          14 :             OK (GrB_Matrix_apply_BinaryOp2nd_INT32 (A, NULL, NULL,
+     118             :                 GrB_MAX_INT32, A, 1, NULL)) ;
+     119             :         }
+     120             : 
+     121             :         // create the graph
+     122          29 :         OK (LAGraph_New (&G, &A, kind, msg)) ;
+     123          29 :         OK (LAGraph_CheckGraph (G, msg)) ;
+     124          29 :         TEST_CHECK (A == NULL) ;    // A has been moved into G->A
+     125             : 
+     126             :         // no need to compute emin; just use a bound
+     127          29 :         OK (GrB_Scalar_new (&(G->emin), GrB_INT32)) ;
+     128          29 :         OK (GrB_Scalar_setElement (G->emin, 1)) ;
+     129             : 
+     130             :         // delta values to try
+     131          29 :         int32_t Deltas [ ] = { 30, 100, 50000 } ;
+     132             : 
+     133             :         // run the SSSP
+     134          29 :         GrB_Vector path_length = NULL ;
+     135          29 :         int64_t step = (n > 100) ? (3*n/4) : ((n/4) + 1) ;
+     136             :         // int64_t src = 0 ;
+     137         119 :         for (int64_t src = 0 ; src < n ; src += step)
+     138             :         {
+     139             :             // int32_t kk = 0 ;
+     140         328 :             for (int32_t kk = 0 ; kk < ((n > 100) ? 1 : 3) ; kk++)
+     141             :             {
+     142         238 :                 int32_t delta = Deltas [kk] ;
+     143         238 :                 printf ("src %d delta %d n %d\n", (int) src, delta, (int) n) ;
+     144         238 :                 OK (GrB_Scalar_setElement (Delta, delta)) ;
+     145         238 :                 OK (LAGr_SingleSourceShortestPath (&path_length, G,
+     146             :                     src, Delta, msg)) ;
+     147         238 :                 int res = LG_check_sssp (path_length, G, src, msg) ;
+     148         238 :                 if (res != GrB_SUCCESS) printf ("res: %d msg: %s\n", res, msg) ;
+     149         238 :                 OK (res) ;
+     150         238 :                 OK (GrB_free(&path_length)) ;
+     151             :             }
+     152             :         }
+     153             : 
+     154             :         // add a single negative edge and try again
+     155          29 :         OK (GrB_free (&(G->emin))) ;
+     156          29 :         G->emin_state = LAGRAPH_UNKNOWN ;
+     157          29 :         OK (GrB_Matrix_setElement_INT32 (G->A, -1, 0, 1)) ;
+     158          29 :         OK (GrB_Scalar_setElement (Delta, 30)) ;
+     159          29 :         OK (LAGr_SingleSourceShortestPath (&path_length, G, 0, Delta, msg)) ;
+     160          29 :         OK (LAGraph_Vector_Print (path_length, LAGraph_SHORT, stdout, msg)) ;
+     161          29 :         int32_t len = 0 ;
+     162          29 :         OK (GrB_Vector_extractElement (&len, path_length, 1)) ;
+     163          29 :         TEST_CHECK (len == -1) ;
+     164          29 :         OK (GrB_free(&path_length)) ;
+     165             : 
+     166          29 :         OK (LAGraph_Delete (&G, msg)) ;
+     167             :     }
+     168             : 
+     169           1 :     GrB_free (&Delta) ;
+     170           1 :     LAGraph_Finalize(msg);
+     171           1 : }
+     172             : 
+     173             : //------------------------------------------------------------------------------
+     174             : // test_SingleSourceShortestPath_types
+     175             : //------------------------------------------------------------------------------
+     176             : 
+     177           1 : void test_SingleSourceShortestPath_types (void)
+     178             : {
+     179           1 :     LAGraph_Init (msg) ;
+     180           1 :     GrB_Matrix A = NULL, T = NULL ;
+     181           1 :     GrB_Scalar Delta = NULL ;
+     182           1 :     OK (GrB_Scalar_new (&Delta, GrB_INT32)) ;
+     183             : 
+     184           1 :     for (int k = 0 ; ; k++)
+     185          29 :     {
+     186             : 
+     187             :         // load the adjacency matrix as A
+     188          30 :         const char *aname = files [k].name ;
+     189          30 :         LAGraph_Kind kind = LAGraph_ADJACENCY_DIRECTED ;
+     190             :         // LAGraph_Kind kind = files [k].kind ;
+     191          30 :         if (strlen (aname) == 0) break;
+     192          29 :         TEST_CASE (aname) ;
+     193          29 :         printf ("\nMatrix: %s\n", aname) ;
+     194          29 :         snprintf (filename, LEN, LG_DATA_DIR "%s", aname) ;
+     195          29 :         FILE *f = fopen (filename, "r") ;
+     196          29 :         TEST_CHECK (f != NULL) ;
+     197          29 :         OK (LAGraph_MMRead (&A, f, msg)) ;
+     198          29 :         OK (fclose (f)) ;
+     199          29 :         TEST_MSG ("Loading of adjacency matrix failed") ;
+     200             : 
+     201          29 :         GrB_Index n = 0, ncols = 1 ;
+     202          29 :         OK (GrB_Matrix_nrows (&n, A)) ;
+     203          29 :         OK (GrB_Matrix_ncols (&ncols, A)) ;
+     204          29 :         TEST_CHECK (n == ncols) ;
+     205             : 
+     206             :         // ensure A has the right type
+     207          29 :         OK (LAGraph_Matrix_TypeName (atype_name, A, msg)) ;
+     208             : //      fprintf (stderr, "matrix %s type: %s\n", aname, atype_name) ;
+     209          29 :         if (MATCHNAME (atype_name, "int32_t"))
+     210             :         {
+     211             :             // use A as-is, but ensure it's positive and nonzero,
+     212             :             // and in range 1 to 255
+     213           1 :             OK (GrB_apply (A, NULL, NULL, GrB_ABS_INT32, A, NULL)) ;
+     214           1 :             OK (GrB_apply (A, NULL, NULL, GrB_MAX_INT32, A, 1, NULL)) ;
+     215           1 :             OK (GrB_apply (A, NULL, NULL, GrB_MIN_INT32, A, 255, NULL)) ;
+     216             :         }
+     217          28 :         else if (MATCHNAME (atype_name, "int64_t"))
+     218             :         {
+     219             :             // use A as-is, but ensure it's positive and nonzero,
+     220             :             // and in range 1 to 255
+     221           5 :             OK (GrB_apply (A, NULL, NULL, GrB_ABS_INT64, A, NULL)) ;
+     222           5 :             OK (GrB_apply (A, NULL, NULL, GrB_MAX_INT64, A, 1, NULL)) ;
+     223           5 :             OK (GrB_apply (A, NULL, NULL, GrB_MIN_INT64, A, 255, NULL)) ;
+     224             :         }
+     225          23 :         else if (MATCHNAME (atype_name, "uint32_t"))
+     226             :         {
+     227             :             // use A as-is, but ensure it's nonzero
+     228             :             // and in range 1 to 255
+     229           1 :             OK (GrB_apply (A, NULL, NULL, GrB_MAX_UINT32, A, 1, NULL)) ;
+     230           1 :             OK (GrB_apply (A, NULL, NULL, GrB_MIN_UINT32, A, 255, NULL)) ;
+     231             :         }
+     232          22 :         else if (MATCHNAME (atype_name, "uint64_t"))
+     233             :         {
+     234             :             // use A as-is, but ensure it's nonzero
+     235             :             // and in range 1 to 255
+     236           1 :             OK (GrB_apply (A, NULL, NULL, GrB_MAX_UINT64, A, 1, NULL)) ;
+     237           1 :             OK (GrB_apply (A, NULL, NULL, GrB_MIN_UINT64, A, 255, NULL)) ;
+     238             :         }
+     239          21 :         else if (MATCHNAME (atype_name, "float"))
+     240             :         {
+     241             :             // use A as-is, but ensure it's positive, with values in range
+     242             :             // 1 to 255
+     243           1 :             OK (GrB_apply (A, NULL, NULL, GrB_ABS_FP32, A, NULL)) ;
+     244           1 :             float emax = 0 ;
+     245           1 :             OK (GrB_reduce (&emax, NULL, GrB_MAX_MONOID_FP32, A, NULL)) ;
+     246           1 :             emax = 255. / emax ;
+     247           1 :             OK (GrB_apply (A, NULL, NULL, GrB_TIMES_FP32, A, emax, NULL)) ;
+     248           1 :             OK (GrB_apply (A, NULL, NULL, GrB_MAX_FP32, A, 1, NULL)) ;
+     249             :         }
+     250          20 :         else if (MATCHNAME (atype_name, "double"))
+     251             :         {
+     252             :             // use A as-is, but ensure it's positive, with values in range
+     253             :             // 1 to 255
+     254          12 :             OK (GrB_apply (A, NULL, NULL, GrB_ABS_FP64, A, NULL)) ;
+     255          12 :             double emax = 0 ;
+     256          12 :             OK (GrB_reduce (&emax, NULL, GrB_MAX_MONOID_FP64, A, NULL)) ;
+     257          12 :             emax = 255. / emax ;
+     258          12 :             OK (GrB_apply (A, NULL, NULL, GrB_TIMES_FP64, A, emax, NULL)) ;
+     259          12 :             OK (GrB_apply (A, NULL, NULL, GrB_MAX_FP64, A, 1, NULL)) ;
+     260             :         }
+     261             :         else
+     262             :         {
+     263             :             // T = max (abs (double (A)), 0.1)
+     264           8 :             OK (GrB_Matrix_new (&T, GrB_FP64, n, n)) ;
+     265           8 :             OK (GrB_apply (T, NULL, NULL, GrB_ABS_FP64, A, NULL)) ;
+     266           8 :             OK (GrB_apply (T, NULL, NULL, GrB_MAX_FP64, A, 0.1, NULL)) ;
+     267           8 :             OK (GrB_free (&A)) ;
+     268           8 :             A = T ;
+     269             :         }
+     270             : 
+     271             :         // create the graph
+     272          29 :         OK (LAGraph_New (&G, &A, kind, msg)) ;
+     273          29 :         OK (LAGraph_CheckGraph (G, msg)) ;
+     274          29 :         TEST_CHECK (A == NULL) ;    // A has been moved into G->A
+     275             : 
+     276             :         // find the smallest entry
+     277          29 :         OK (LAGraph_Cached_EMin (G, msg)) ;
+     278             : 
+     279             :         // delta values to try
+     280          29 :         int32_t Deltas [ ] = { 30, 100, 50000 } ;
+     281             : 
+     282             :         // run the SSSP
+     283          29 :         GrB_Vector path_length = NULL ;
+     284          29 :         int64_t step = (n > 100) ? (3*n/4) : ((n/4) + 1) ;
+     285         119 :         for (int64_t src = 0 ; src < n ; src += step)
+     286             :         {
+     287         328 :             for (int32_t kk = 0 ; kk < ((n > 100) ? 1 : 3) ; kk++)
+     288             :             {
+     289         238 :                 int32_t delta = Deltas [kk] ;
+     290         238 :                 printf ("src %d delta %d n %d\n", (int) src, delta, (int) n) ;
+     291         238 :                 OK (GrB_Scalar_setElement (Delta, delta)) ;
+     292         238 :                 OK (LAGr_SingleSourceShortestPath (&path_length, G, src,
+     293             :                     Delta, msg)) ;
+     294         238 :                 int res = LG_check_sssp (path_length, G, src, msg) ;
+     295         238 :                 if (res != GrB_SUCCESS) printf ("res: %d msg: %s\n", res, msg) ;
+     296         238 :                 OK (res) ;
+     297         238 :                 OK (GrB_free(&path_length)) ;
+     298             :             }
+     299             :         }
+     300             : 
+     301          29 :         OK (LAGraph_Delete (&G, msg)) ;
+     302             :     }
+     303             : 
+     304           1 :     GrB_free (&Delta) ;
+     305           1 :     LAGraph_Finalize (msg) ;
+     306           1 : }
+     307             : 
+     308             : //------------------------------------------------------------------------------
+     309             : // test_SingleSourceShortestPath_failure
+     310             : //------------------------------------------------------------------------------
+     311             : 
+     312           1 : void test_SingleSourceShortestPath_failure (void)
+     313             : {
+     314           1 :     LAGraph_Init (msg) ;
+     315           1 :     GrB_Scalar Delta = NULL ;
+     316           1 :     OK (GrB_Scalar_new (&Delta, GrB_INT32)) ;
+     317           1 :     OK (GrB_Scalar_setElement (Delta, 1)) ;
+     318             : 
+     319             :     // load the karate adjacency matrix as A
+     320           1 :     GrB_Matrix A = NULL ;
+     321           1 :     FILE *f = fopen (LG_DATA_DIR "karate.mtx", "r") ;
+     322           1 :     TEST_CHECK (f != NULL) ;
+     323           1 :     OK (LAGraph_MMRead (&A, f, msg)) ;
+     324           1 :     OK (fclose (f)) ;
+     325           1 :     TEST_MSG ("Loading of adjacency matrix failed") ;
+     326             : 
+     327             :     // create the graph
+     328           1 :     OK (LAGraph_New (&G, &A, LAGraph_ADJACENCY_DIRECTED, msg)) ;
+     329           1 :     OK (LAGraph_CheckGraph (G, msg)) ;
+     330           1 :     TEST_CHECK (A == NULL) ;    // A has been moved into G->A
+     331             : 
+     332           1 :     GrB_Vector path_length = NULL ;
+     333           1 :     int result = LAGr_SingleSourceShortestPath (&path_length, G, 0, Delta, msg) ;
+     334           1 :     printf ("\nres: %d msg: %s\n", result, msg) ;
+     335           1 :     TEST_CHECK (path_length == NULL) ;
+     336           1 :     TEST_CHECK (result == GrB_NOT_IMPLEMENTED) ;
+     337             : 
+     338           1 :     OK (GrB_Scalar_clear (Delta)) ;
+     339           1 :     result = LAGr_SingleSourceShortestPath (&path_length, G, 0, Delta, msg) ;
+     340           1 :     printf ("\nres: %d msg: %s\n", result, msg) ;
+     341           1 :     TEST_CHECK (path_length == NULL) ;
+     342           1 :     TEST_CHECK (result == GrB_EMPTY_OBJECT) ;
+     343             : 
+     344           1 :     OK (GrB_free (&Delta)) ;
+     345           1 :     OK (LAGraph_Delete (&G, msg)) ;
+     346           1 :     LAGraph_Finalize (msg) ;
+     347           1 : }
+     348             : 
+     349             : //------------------------------------------------------------------------------
+     350             : // test_SingleSourceShortestPath_brutal
+     351             : //------------------------------------------------------------------------------
+     352             : 
+     353             : #if LAGRAPH_SUITESPARSE
+     354           1 : void test_SingleSourceShortestPath_brutal (void)
+     355             : {
+     356           1 :     OK (LG_brutal_setup (msg)) ;
+     357           1 :     GrB_Scalar Delta = NULL ;
+     358           1 :     OK (GrB_Scalar_new (&Delta, GrB_INT32)) ;
+     359             : 
+     360           1 :     GrB_Matrix A = NULL, T = NULL ;
+     361             : 
+     362             :     // just test with the first 8 matrices
+     363           9 :     for (int k = 0 ; k < 8 ; k++)
+     364             :     {
+     365             : 
+     366             :         // load the adjacency matrix as A
+     367           8 :         const char *aname = files [k].name ;
+     368           8 :         LAGraph_Kind kind = LAGraph_ADJACENCY_DIRECTED ;
+     369             :         // LAGraph_Kind kind = files [k].kind ;
+     370           8 :         if (strlen (aname) == 0) break;
+     371           8 :         TEST_CASE (aname) ;
+     372           8 :         printf ("\nMatrix: %s\n", aname) ;
+     373           8 :         snprintf (filename, LEN, LG_DATA_DIR "%s", aname) ;
+     374           8 :         FILE *f = fopen (filename, "r") ;
+     375           8 :         TEST_CHECK (f != NULL) ;
+     376           8 :         OK (LAGraph_MMRead (&A, f, msg)) ;
+     377           8 :         OK (fclose (f)) ;
+     378           8 :         TEST_MSG ("Loading of adjacency matrix failed") ;
+     379             : 
+     380           8 :         GrB_Index n = 0 ;
+     381           8 :         OK (GrB_Matrix_nrows (&n, A)) ;
+     382           8 :         if (n > 30)
+     383             :         {
+     384           1 :             printf ("skipped -- only using small matrices for brutal test\n") ;
+     385           1 :             OK (GrB_free (&A)) ;
+     386           1 :             continue ;
+     387             :         }
+     388             : 
+     389             :         // convert A to int32
+     390           7 :         OK (LAGraph_Matrix_TypeName (atype_name, A, msg)) ;
+     391           7 :         if (!MATCHNAME (atype_name, "int32_t"))
+     392             :         {
+     393           6 :             OK (GrB_Matrix_new (&T, GrB_INT32, n, n)) ;
+     394           6 :             OK (GrB_assign (T, NULL, NULL, A, GrB_ALL, n, GrB_ALL, n, NULL)) ;
+     395           6 :             OK (GrB_free (&A)) ;
+     396           6 :             A = T ;
+     397             :         }
+     398             : 
+     399             :         // ensure all entries are positive, and in the range 1 to 255
+     400           7 :         OK (GrB_Matrix_apply_BinaryOp2nd_INT32 (A, NULL, NULL,
+     401             :             GrB_BAND_INT32, A, 255, NULL)) ;
+     402             :         int32_t x ;
+     403           7 :         OK (GrB_reduce (&x, NULL, GrB_MIN_MONOID_INT32, A, NULL)) ;
+     404           7 :         if (x < 1)
+     405             :         {
+     406           2 :             OK (GrB_Matrix_apply_BinaryOp2nd_INT32 (A, NULL, NULL,
+     407             :                 GrB_MAX_INT32, A, 1, NULL)) ;
+     408             :         }
+     409             : 
+     410             :         // create the graph
+     411           7 :         OK (LAGraph_New (&G, &A, kind, msg)) ;
+     412           7 :         OK (LAGraph_CheckGraph (G, msg)) ;
+     413             : 
+     414             :         // run the SSSP on a single source node with one delta
+     415           7 :         GrB_Vector path_length = NULL ;
+     416           7 :         int64_t src = 0 ;
+     417           7 :         int32_t delta = 30 ;
+     418           7 :         printf ("src %d delta %d n %d\n", (int) src, delta, (int) n) ;
+     419           7 :         OK (GrB_Scalar_setElement (Delta, delta)) ;
+     420        1276 :         LG_BRUTAL (LAGr_SingleSourceShortestPath (&path_length, G, src,
+     421             :             Delta, msg)) ;
+     422           7 :         int rr = (LG_check_sssp (path_length, G, src, msg)) ;
+     423           7 :         printf ("rr %d msg %s\n", rr, msg) ;
+     424           7 :         OK (rr) ;
+     425           7 :         OK (GrB_free(&path_length)) ;
+     426             : 
+     427             :         // add a single negative edge and try again
+     428           7 :         OK (GrB_Matrix_setElement_INT32 (G->A, -1, 0, 1)) ;
+     429           7 :         OK (GrB_wait (G->A, GrB_MATERIALIZE)) ;
+     430        2172 :         LG_BRUTAL (LAGr_SingleSourceShortestPath (&path_length, G, 0,
+     431             :             Delta, msg)) ;
+     432           7 :         int32_t len = 0 ;
+     433           7 :         OK (GrB_Vector_extractElement (&len, path_length, 1)) ;
+     434           7 :         TEST_CHECK (len == -1) ;
+     435           7 :         OK (GrB_free(&path_length)) ;
+     436             : 
+     437           7 :         OK (LAGraph_Delete (&G, msg)) ;
+     438             :     }
+     439             : 
+     440           1 :     GrB_free (&Delta) ;
+     441           1 :     OK (LG_brutal_teardown (msg)) ;
+     442           1 : }
+     443             : #endif
+     444             : 
+     445             : //****************************************************************************
+     446             : //****************************************************************************
+     447             : 
+     448             : TEST_LIST = {
+     449             :     {"SSSP", test_SingleSourceShortestPath},
+     450             :     {"SSSP_types", test_SingleSourceShortestPath_types},
+     451             :     {"SSSP_failure", test_SingleSourceShortestPath_failure},
+     452             :     #if LAGRAPH_SUITESPARSE
+     453             :     {"SSSP_brutal", test_SingleSourceShortestPath_brutal },
+     454             :     #endif
+     455             :     {NULL, NULL}
+     456             : };
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_Sort.c.func-sort-c.html b/src/test/test_Sort.c.func-sort-c.html new file mode 100644 index 0000000000..6b21ee1fc8 --- /dev/null +++ b/src/test/test_Sort.c.func-sort-c.html @@ -0,0 +1,96 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_Sort.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_Sort.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:142142100.0 %
Date:2024-08-29 20:08:04Functions:66100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_sort11
test_sort1_brutal1
test_sort21
test_sort2_brutal1
test_sort31
test_sort3_brutal1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_Sort.c.func.html b/src/test/test_Sort.c.func.html new file mode 100644 index 0000000000..49f9460802 --- /dev/null +++ b/src/test/test_Sort.c.func.html @@ -0,0 +1,96 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_Sort.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_Sort.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:142142100.0 %
Date:2024-08-29 20:08:04Functions:66100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_sort11
test_sort1_brutal1
test_sort21
test_sort2_brutal1
test_sort31
test_sort3_brutal1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_Sort.c.gcov.html b/src/test/test_Sort.c.gcov.html new file mode 100644 index 0000000000..41f54ba861 --- /dev/null +++ b/src/test/test_Sort.c.gcov.html @@ -0,0 +1,430 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_Sort.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_Sort.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:142142100.0 %
Date:2024-08-29 20:08:04Functions:66100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //-----------------------------------------------------------------------------
+       2             : // LAGraph/src/test/test_Sort.c: test LG_msort* methods
+       3             : //-----------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //-----------------------------------------------------------------------------
+      17             : 
+      18             : #include "LAGraph_test.h"
+      19             : #include "LG_internal.h"
+      20             : 
+      21             : char msg [LAGRAPH_MSG_LEN] ;
+      22             : 
+      23             : //-----------------------------------------------------------------------------
+      24             : // test_sort1
+      25             : //-----------------------------------------------------------------------------
+      26             : 
+      27           1 : void test_sort1 (void)
+      28             : {
+      29           1 :     OK (LAGraph_Init (msg)) ;
+      30           1 :     OK (LAGraph_SetNumThreads (1, 4, msg)) ;
+      31             : 
+      32           3 :     for (int trial = 0 ; trial <= 1 ; trial++)
+      33             :     {
+      34           2 :         int64_t n = (trial == 0) ? 1024 : (256 * 1024) ;
+      35             : 
+      36             :         int64_t *A0 ;
+      37           2 :         OK (LAGraph_Malloc ((void **) &A0, n, sizeof (int64_t), msg)) ;
+      38             : 
+      39           2 :         uint64_t seed = 1 ;
+      40      263170 :         for (int k = 0 ; k < n ; k++)
+      41             :         {
+      42      263168 :             A0 [k] = (int64_t) LG_Random15 (&seed) ;
+      43             :         }
+      44             : 
+      45           2 :         OK (LG_msort1 (A0, n, msg)) ;
+      46             : 
+      47      263168 :         for (int k = 1 ; k < n ; k++)
+      48             :         {
+      49      263166 :             TEST_CHECK (A0 [k-1] <= A0 [k]) ;
+      50             :         }
+      51             : 
+      52      263170 :         for (int k = 0 ; k < n ; k++)
+      53             :         {
+      54      263168 :             A0 [k] = (int64_t) (LG_Random15 (&seed) % 4) ;
+      55             :         }
+      56             : 
+      57           2 :         OK (LG_msort1 (A0, n, msg)) ;
+      58             : 
+      59      263168 :         for (int k = 1 ; k < n ; k++)
+      60             :         {
+      61      263166 :             TEST_CHECK (A0 [k-1] <= A0 [k]) ;
+      62             :         }
+      63             : 
+      64           2 :         LAGraph_Free ((void **) &A0, NULL) ;
+      65             :     }
+      66             : 
+      67           1 :     OK (LAGraph_Finalize (msg)) ;
+      68           1 : }
+      69             : 
+      70             : //-----------------------------------------------------------------------------
+      71             : // test_sort2
+      72             : //-----------------------------------------------------------------------------
+      73             : 
+      74           1 : void test_sort2 (void)
+      75             : {
+      76           1 :     OK (LAGraph_Init (msg)) ;
+      77           1 :     OK (LAGraph_SetNumThreads (1, 4, msg)) ;
+      78             : 
+      79           1 :     int64_t n = 256 * 1024 ;
+      80             : 
+      81             :     int64_t *A0, *A1 ;
+      82           1 :     OK (LAGraph_Malloc ((void **) &A0, n, sizeof (int64_t), msg)) ;
+      83           1 :     OK (LAGraph_Malloc ((void **) &A1, n, sizeof (int64_t), msg)) ;
+      84             : 
+      85           1 :     uint64_t seed = 1 ;
+      86      262145 :     for (int k = 0 ; k < n ; k++)
+      87             :     {
+      88      262144 :         A0 [k] = (int64_t) LG_Random15 (&seed) ;
+      89      262144 :         A1 [k] = (int64_t) LG_Random60 (&seed) ;
+      90             :     }
+      91             : 
+      92           1 :     OK (LG_msort2 (A0, A1, n, msg)) ;
+      93             : 
+      94      262144 :     for (int k = 1 ; k < n ; k++)
+      95             :     {
+      96      262143 :         TEST_CHECK (LG_lt_2 (A0, A1, k-1, A0, A1, k)
+      97             :             || (A0 [k-1] == A0 [k] && A1 [k-1] == A1 [k])) ;
+      98             :     }
+      99             : 
+     100      262145 :     for (int k = 0 ; k < n ; k++)
+     101             :     {
+     102      262144 :         A0 [k] = 0 ;
+     103      262144 :         A1 [k] = (int64_t) (LG_Random15 (&seed) % 4) ;
+     104             :     }
+     105             : 
+     106           1 :     OK (LG_msort2 (A0, A1, n, msg)) ;
+     107             : 
+     108      262144 :     for (int k = 1 ; k < n ; k++)
+     109             :     {
+     110      262143 :         TEST_CHECK (LG_lt_2 (A0, A1, k-1, A0, A1, k)
+     111             :             || (A0 [k-1] == A0 [k] && A1 [k-1] == A1 [k])) ;
+     112             :     }
+     113             : 
+     114           1 :     LAGraph_Free ((void **) &A0, NULL) ;
+     115           1 :     LAGraph_Free ((void **) &A1, NULL) ;
+     116             : 
+     117           1 :     OK (LAGraph_Finalize (msg)) ;
+     118           1 : }
+     119             : 
+     120             : //-----------------------------------------------------------------------------
+     121             : // test_sort3
+     122             : //-----------------------------------------------------------------------------
+     123             : 
+     124           1 : void test_sort3 (void)
+     125             : {
+     126           1 :     OK (LAGraph_Init (msg)) ;
+     127           1 :     OK (LAGraph_SetNumThreads (1, 4, msg)) ;
+     128             : 
+     129           1 :     int64_t n = 256 * 1024 ;
+     130           1 :     printf ("test sort3\n") ;
+     131             : 
+     132             :     int64_t *A0, *A1, *A2 ;
+     133           1 :     OK (LAGraph_Malloc ((void **) &A0, n, sizeof (int64_t), msg)) ;
+     134           1 :     OK (LAGraph_Malloc ((void **) &A1, n, sizeof (int64_t), msg)) ;
+     135           1 :     OK (LAGraph_Malloc ((void **) &A2, n, sizeof (int64_t), msg)) ;
+     136             : 
+     137           1 :     uint64_t seed = 1 ;
+     138      262145 :     for (int k = 0 ; k < n ; k++)
+     139             :     {
+     140      262144 :         A0 [k] = (int64_t) LG_Random15 (&seed) ;
+     141      262144 :         A1 [k] = (int64_t) LG_Random60 (&seed) ;
+     142      262144 :         A2 [k] = (int64_t) LG_Random60 (&seed) ;
+     143             :     }
+     144             : 
+     145           1 :     OK (LG_msort3 (A0, A1, A2, n, msg)) ;
+     146             : 
+     147      262144 :     for (int k = 1 ; k < n ; k++)
+     148             :     {
+     149      262143 :         TEST_CHECK (LG_lt_3 (A0, A1, A2, k-1, A0, A1, A2, k)
+     150             :             || (A0 [k-1] == A0 [k] &&
+     151             :                 A1 [k-1] == A1 [k] &&
+     152             :                 A2 [k-1] == A2 [k])) ;
+     153             :     }
+     154             : 
+     155      262145 :     for (int k = 0 ; k < n ; k++)
+     156             :     {
+     157      262144 :         A0 [k] = 0 ;
+     158      262144 :         A1 [k] = (int64_t) (LG_Random15 (&seed) % 4) ;
+     159      262144 :         A2 [k] = (int64_t) (LG_Random15 (&seed) % 4) ;
+     160             :     }
+     161             : 
+     162           1 :     OK (LG_msort3 (A0, A1, A2, n, msg)) ;
+     163             : 
+     164      262144 :     for (int k = 1 ; k < n ; k++)
+     165             :     {
+     166      262143 :         TEST_CHECK (LG_lt_3 (A0, A1, A2, k-1, A0, A1, A2, k)
+     167             :             || (A0 [k-1] == A0 [k] &&
+     168             :                 A1 [k-1] == A1 [k] &&
+     169             :                 A2 [k-1] == A2 [k])) ;
+     170             :     }
+     171             : 
+     172           1 :     LAGraph_Free ((void **) &A0, NULL) ;
+     173           1 :     LAGraph_Free ((void **) &A1, NULL) ;
+     174           1 :     LAGraph_Free ((void **) &A2, NULL) ;
+     175             : 
+     176           1 :     OK (LAGraph_Finalize (msg)) ;
+     177           1 : }
+     178             : 
+     179             : //-----------------------------------------------------------------------------
+     180             : // test_sort1_brutal
+     181             : //-----------------------------------------------------------------------------
+     182             : 
+     183             : #if LAGRAPH_SUITESPARSE
+     184           1 : void test_sort1_brutal (void)
+     185             : {
+     186           1 :     OK (LG_brutal_setup (msg)) ;
+     187           1 :     OK (LAGraph_SetNumThreads (1, 4, msg)) ;
+     188             : 
+     189           3 :     for (int trial = 0 ; trial <= 1 ; trial++)
+     190             :     {
+     191           2 :         int64_t n = (trial == 0) ? 1024 : (256 * 1024) ;
+     192             : 
+     193             :         int64_t *A0 ;
+     194           2 :         OK (LAGraph_Malloc ((void **) &A0, n, sizeof (int64_t), msg)) ;
+     195             : 
+     196           2 :         uint64_t seed = 1 ;
+     197      263170 :         for (int k = 0 ; k < n ; k++)
+     198             :         {
+     199      263168 :             A0 [k] = (int64_t) LG_Random15 (&seed) ;
+     200             :         }
+     201             : 
+     202           3 :         LG_BRUTAL (LG_msort1 (A0, n, msg)) ;
+     203             : 
+     204      263168 :         for (int k = 1 ; k < n ; k++)
+     205             :         {
+     206      263166 :             TEST_CHECK (A0 [k-1] <= A0 [k]) ;
+     207             :         }
+     208             : 
+     209      263170 :         for (int k = 0 ; k < n ; k++)
+     210             :         {
+     211      263168 :             A0 [k] = (int64_t) (LG_Random15 (&seed) % 4) ;
+     212             :         }
+     213             : 
+     214           3 :         LG_BRUTAL (LG_msort1 (A0, n, msg)) ;
+     215             : 
+     216      263168 :         for (int k = 1 ; k < n ; k++)
+     217             :         {
+     218      263166 :             TEST_CHECK (A0 [k-1] <= A0 [k]) ;
+     219             :         }
+     220             : 
+     221           2 :         LAGraph_Free ((void **) &A0, NULL) ;
+     222             :     }
+     223             : 
+     224           1 :     OK (LG_brutal_teardown (msg)) ;
+     225           1 : }
+     226             : #endif
+     227             : 
+     228             : //-----------------------------------------------------------------------------
+     229             : // test_sort2_brutal
+     230             : //-----------------------------------------------------------------------------
+     231             : 
+     232             : #if LAGRAPH_SUITESPARSE
+     233           1 : void test_sort2_brutal (void)
+     234             : {
+     235           1 :     OK (LG_brutal_setup (msg)) ;
+     236           1 :     OK (LAGraph_SetNumThreads (1, 4, msg)) ;
+     237             : 
+     238           1 :     int64_t n = 256 * 1024 ;
+     239             : 
+     240             :     int64_t *A0, *A1 ;
+     241           1 :     OK (LAGraph_Malloc ((void **) &A0, n, sizeof (int64_t), msg)) ;
+     242           1 :     OK (LAGraph_Malloc ((void **) &A1, n, sizeof (int64_t), msg)) ;
+     243             : 
+     244           1 :     uint64_t seed = 1 ;
+     245      262145 :     for (int k = 0 ; k < n ; k++)
+     246             :     {
+     247      262144 :         A0 [k] = (int64_t) LG_Random15 (&seed) ;
+     248      262144 :         A1 [k] = (int64_t) LG_Random60 (&seed) ;
+     249             :     }
+     250             : 
+     251           2 :     LG_BRUTAL (LG_msort2 (A0, A1, n, msg)) ;
+     252             : 
+     253      262144 :     for (int k = 1 ; k < n ; k++)
+     254             :     {
+     255      262143 :         TEST_CHECK (LG_lt_2 (A0, A1, k-1, A0, A1, k)
+     256             :             || (A0 [k-1] == A0 [k] && A1 [k-1] == A1 [k])) ;
+     257             :     }
+     258             : 
+     259      262145 :     for (int k = 0 ; k < n ; k++)
+     260             :     {
+     261      262144 :         A0 [k] = 0 ;
+     262      262144 :         A1 [k] = (int64_t) (LG_Random15 (&seed) % 4) ;
+     263             :     }
+     264             : 
+     265           2 :     LG_BRUTAL (LG_msort2 (A0, A1, n, msg)) ;
+     266             : 
+     267      262144 :     for (int k = 1 ; k < n ; k++)
+     268             :     {
+     269      262143 :         TEST_CHECK (LG_lt_2 (A0, A1, k-1, A0, A1, k)
+     270             :             || (A0 [k-1] == A0 [k] && A1 [k-1] == A1 [k])) ;
+     271             :     }
+     272             : 
+     273           1 :     LAGraph_Free ((void **) &A0, NULL) ;
+     274           1 :     LAGraph_Free ((void **) &A1, NULL) ;
+     275             : 
+     276           1 :     OK (LG_brutal_teardown (msg)) ;
+     277           1 : }
+     278             : #endif
+     279             : 
+     280             : //-----------------------------------------------------------------------------
+     281             : // test_sort3_brutal
+     282             : //-----------------------------------------------------------------------------
+     283             : 
+     284           1 : void test_sort3_brutal (void)
+     285             : {
+     286           1 :     OK (LG_brutal_setup (msg)) ;
+     287           1 :     OK (LAGraph_SetNumThreads (1, 4, msg)) ;
+     288             : 
+     289           1 :     int64_t n = 256 * 1024 ;
+     290           1 :     printf ("test sort3\n") ;
+     291             : 
+     292             :     int64_t *A0, *A1, *A2 ;
+     293           1 :     OK (LAGraph_Malloc ((void **) &A0, n, sizeof (int64_t), msg)) ;
+     294           1 :     OK (LAGraph_Malloc ((void **) &A1, n, sizeof (int64_t), msg)) ;
+     295           1 :     OK (LAGraph_Malloc ((void **) &A2, n, sizeof (int64_t), msg)) ;
+     296             : 
+     297           1 :     uint64_t seed = 1 ;
+     298      262145 :     for (int k = 0 ; k < n ; k++)
+     299             :     {
+     300      262144 :         A0 [k] = (int64_t) LG_Random15 (&seed) ;
+     301      262144 :         A1 [k] = (int64_t) LG_Random60 (&seed) ;
+     302      262144 :         A2 [k] = (int64_t) LG_Random60 (&seed) ;
+     303             :     }
+     304             : 
+     305           2 :     LG_BRUTAL (LG_msort3 (A0, A1, A2, n, msg)) ;
+     306             : 
+     307      262144 :     for (int k = 1 ; k < n ; k++)
+     308             :     {
+     309      262143 :         TEST_CHECK (LG_lt_3 (A0, A1, A2, k-1, A0, A1, A2, k)
+     310             :             || (A0 [k-1] == A0 [k] &&
+     311             :                 A1 [k-1] == A1 [k] &&
+     312             :                 A2 [k-1] == A2 [k])) ;
+     313             :     }
+     314             : 
+     315      262145 :     for (int k = 0 ; k < n ; k++)
+     316             :     {
+     317      262144 :         A0 [k] = 0 ;
+     318      262144 :         A1 [k] = (int64_t) (LG_Random15 (&seed) % 4) ;
+     319      262144 :         A2 [k] = (int64_t) (LG_Random15 (&seed) % 4) ;
+     320             :     }
+     321             : 
+     322           2 :     LG_BRUTAL (LG_msort3 (A0, A1, A2, n, msg)) ;
+     323             : 
+     324      262144 :     for (int k = 1 ; k < n ; k++)
+     325             :     {
+     326      262143 :         TEST_CHECK (LG_lt_3 (A0, A1, A2, k-1, A0, A1, A2, k)
+     327             :             || (A0 [k-1] == A0 [k] &&
+     328             :                 A1 [k-1] == A1 [k] &&
+     329             :                 A2 [k-1] == A2 [k])) ;
+     330             :     }
+     331             : 
+     332           1 :     LAGraph_Free ((void **) &A0, NULL) ;
+     333           1 :     LAGraph_Free ((void **) &A1, NULL) ;
+     334           1 :     LAGraph_Free ((void **) &A2, NULL) ;
+     335             : 
+     336           1 :     OK (LG_brutal_teardown (msg)) ;
+     337           1 : }
+     338             : 
+     339             : 
+     340             : //-----------------------------------------------------------------------------
+     341             : // TEST_LIST: the list of tasks for this entire test
+     342             : //-----------------------------------------------------------------------------
+     343             : 
+     344             : TEST_LIST = {
+     345             :     {"test_sort1", test_sort1},
+     346             :     {"test_sort2", test_sort2},
+     347             :     {"test_sort3", test_sort3},
+     348             :     #if LAGRAPH_SUITESPARSE
+     349             :     {"test_sort1_brutal", test_sort1_brutal},
+     350             :     {"test_sort2_brutal", test_sort2_brutal},
+     351             :     {"test_sort3_brutal", test_sort3_brutal},
+     352             :     #endif
+     353             :     {NULL, NULL}
+     354             : };
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_SortByDegree.c.func-sort-c.html b/src/test/test_SortByDegree.c.func-sort-c.html new file mode 100644 index 0000000000..3c1bd35336 --- /dev/null +++ b/src/test/test_SortByDegree.c.func-sort-c.html @@ -0,0 +1,92 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_SortByDegree.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_SortByDegree.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:190190100.0 %
Date:2024-08-29 20:08:04Functions:55100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_SortByDegree1
test_SortByDegree_brutal1
test_SortByDegree_failures1
setup2
teardown2
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_SortByDegree.c.func.html b/src/test/test_SortByDegree.c.func.html new file mode 100644 index 0000000000..9ba5bd2d5c --- /dev/null +++ b/src/test/test_SortByDegree.c.func.html @@ -0,0 +1,92 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_SortByDegree.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_SortByDegree.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:190190100.0 %
Date:2024-08-29 20:08:04Functions:55100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
setup2
teardown2
test_SortByDegree1
test_SortByDegree_brutal1
test_SortByDegree_failures1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_SortByDegree.c.gcov.html b/src/test/test_SortByDegree.c.gcov.html new file mode 100644 index 0000000000..724a9d0e79 --- /dev/null +++ b/src/test/test_SortByDegree.c.gcov.html @@ -0,0 +1,510 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_SortByDegree.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_SortByDegree.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:190190100.0 %
Date:2024-08-29 20:08:04Functions:55100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph/src/test/test_SortByDegree  test LAGr_SortByDegree
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include "LAGraph_test.h"
+      19             : 
+      20             : //------------------------------------------------------------------------------
+      21             : // global variables
+      22             : //------------------------------------------------------------------------------
+      23             : 
+      24             : LAGraph_Graph G = NULL, H = NULL ;
+      25             : char msg [LAGRAPH_MSG_LEN] ;
+      26             : GrB_Matrix A = NULL, B = NULL ;
+      27             : GrB_Vector d = NULL ;
+      28             : #define LEN 512
+      29             : char filename [LEN+1] ;
+      30             : int64_t *P = NULL ;
+      31             : bool *W = NULL ;
+      32             : GrB_Index n, nrows, ncols ;
+      33             : bool is_symmetric ;
+      34             : int kind ;
+      35             : 
+      36             : //------------------------------------------------------------------------------
+      37             : // setup: start a test
+      38             : //------------------------------------------------------------------------------
+      39             : 
+      40           2 : void setup (void)
+      41             : {
+      42           2 :     OK (LAGraph_Init (msg)) ;
+      43           2 : }
+      44             : 
+      45             : //------------------------------------------------------------------------------
+      46             : // teardown: finalize a test
+      47             : //------------------------------------------------------------------------------
+      48             : 
+      49           2 : void teardown (void)
+      50             : {
+      51           2 :     OK (LAGraph_Finalize (msg)) ;
+      52           2 : }
+      53             : 
+      54             : //------------------------------------------------------------------------------
+      55             : // test_SortByDegree  test LAGr_SortByDegree
+      56             : //------------------------------------------------------------------------------
+      57             : 
+      58             : const char *files [ ] =
+      59             : {
+      60             :     "A.mtx",
+      61             :     "LFAT5.mtx",
+      62             :     "cover.mtx",
+      63             :     "full.mtx",
+      64             :     "full_symmetric.mtx",
+      65             :     "karate.mtx",
+      66             :     "ldbc-cdlp-directed-example.mtx",
+      67             :     "ldbc-cdlp-undirected-example.mtx",
+      68             :     "ldbc-directed-example-bool.mtx",
+      69             :     "ldbc-directed-example-unweighted.mtx",
+      70             :     "ldbc-directed-example.mtx",
+      71             :     "ldbc-undirected-example-bool.mtx",
+      72             :     "ldbc-undirected-example-unweighted.mtx",
+      73             :     "ldbc-undirected-example.mtx",
+      74             :     "ldbc-wcc-example.mtx",
+      75             :     "matrix_int16.mtx",
+      76             :     "msf1.mtx",
+      77             :     "msf2.mtx",
+      78             :     "msf3.mtx",
+      79             :     "structure.mtx",
+      80             :     "sample.mtx",
+      81             :     "sample2.mtx",
+      82             :     "skew_fp32.mtx",
+      83             :     "tree-example.mtx",
+      84             :     "west0067.mtx",
+      85             :     "",
+      86             : } ;
+      87             : 
+      88           1 : void test_SortByDegree (void)
+      89             : {
+      90           1 :     setup ( ) ;
+      91             : 
+      92           1 :     for (int kk = 0 ; ; kk++)
+      93          25 :     {
+      94             : 
+      95             :         // get the name of the test matrix
+      96          26 :         const char *aname = files [kk] ;
+      97          26 :         if (strlen (aname) == 0) break;
+      98          25 :         TEST_CASE (aname) ;
+      99          25 :         printf ("\n############################################# %s\n", aname) ;
+     100          25 :         snprintf (filename, LEN, LG_DATA_DIR "%s", aname) ;
+     101             : 
+     102          47 :         for (int outer = 0 ; outer <= 1 ; outer++)
+     103             :         {
+     104             : 
+     105             :             // load the matrix as A
+     106          36 :             FILE *f = fopen (filename, "r") ;
+     107          36 :             TEST_CHECK (f != NULL) ;
+     108          36 :             OK (LAGraph_MMRead (&A, f, msg)) ;
+     109          36 :             OK (fclose (f)) ;
+     110          36 :             TEST_MSG ("Loading of adjacency matrix failed") ;
+     111             : 
+     112             :             // ensure the matrix is square
+     113          36 :             OK (GrB_Matrix_nrows (&nrows, A)) ;
+     114          36 :             OK (GrB_Matrix_ncols (&ncols, A)) ;
+     115          36 :             TEST_CHECK (nrows == ncols) ;
+     116          36 :             n = nrows ;
+     117             : 
+     118             :             // decide if the graph G is directed or undirected
+     119          36 :             if (outer == 0)
+     120             :             {
+     121          25 :                 kind = LAGraph_ADJACENCY_DIRECTED ;
+     122          25 :                 printf ("\n#### case: directed graph\n\n") ;
+     123             :             }
+     124             :             else
+     125             :             {
+     126          11 :                 kind = LAGraph_ADJACENCY_UNDIRECTED ;
+     127          11 :                 printf ("\n#### case: undirected graph\n\n") ;
+     128             :             }
+     129             : 
+     130             :             // construct a graph G with adjacency matrix A
+     131          36 :             TEST_CHECK (A != NULL) ;
+     132          36 :             OK (LAGraph_New (&G, &A, kind, msg)) ;
+     133          36 :             TEST_CHECK (A == NULL) ;
+     134          36 :             TEST_CHECK (G != NULL) ;
+     135             : 
+     136             :             // create the cached properties
+     137          72 :             int ok_result = (kind == LAGraph_ADJACENCY_UNDIRECTED) ?
+     138          36 :                 LAGRAPH_CACHE_NOT_NEEDED : GrB_SUCCESS ;
+     139          36 :             int result = LAGraph_Cached_AT (G, msg) ;
+     140          36 :             TEST_CHECK (result == ok_result) ;
+     141          36 :             OK (LAGraph_Cached_OutDegree (G, msg)) ;
+     142          36 :             result = LAGraph_Cached_InDegree (G, msg) ;
+     143          36 :             TEST_CHECK (result == ok_result) ;
+     144          36 :             OK (LAGraph_Cached_IsSymmetricStructure (G, msg)) ;
+     145          36 :             OK (LAGraph_Graph_Print (G, LAGraph_SHORT, stdout, msg)) ;
+     146             : 
+     147             :             // sort 4 different ways
+     148         180 :             for (int trial = 0 ; trial <= 3 ; trial++)
+     149             :             {
+     150         144 :                 bool byout = (trial == 0 || trial == 1) ;
+     151         144 :                 bool ascending = (trial == 0 || trial == 2) ;
+     152             : 
+     153             :                 // sort the graph by degree
+     154         144 :                 TEST_CHECK (P == NULL) ;
+     155         144 :                 OK (LAGr_SortByDegree (&P, G, byout, ascending, msg)) ;
+     156         144 :                 TEST_CHECK (P != NULL) ;
+     157             : 
+     158             :                 // ensure P is a permutation of 0..n-1
+     159         144 :                 OK (LAGraph_Calloc ((void **) &W, n, sizeof (bool), msg)) ;
+     160        1736 :                 for (int k = 0 ; k < n ; k++)
+     161             :                 {
+     162        1592 :                     int64_t j = P [k] ;
+     163        1592 :                     TEST_CHECK (j >= 0 && j < n) ;
+     164        1592 :                     TEST_CHECK (W [j] == false) ;
+     165        1592 :                     W [j] = true ;
+     166             :                 }
+     167             : 
+     168             :                 // check the result by constructing a new graph with adjacency
+     169             :                 // matrix B = A (P,P)
+     170         144 :                 OK (GrB_Matrix_new (&B, GrB_BOOL, n, n)) ;
+     171         144 :                 OK (GrB_extract (B, NULL, NULL, G->A,
+     172             :                     (GrB_Index *) P, n, (GrB_Index *) P, n, NULL)) ;
+     173         144 :                 OK (LAGraph_New (&H, &B, kind, msg)) ;
+     174         144 :                 TEST_CHECK (B == NULL) ;
+     175         144 :                 TEST_CHECK (H != NULL) ;
+     176             : 
+     177             :                 // get the cached properties of H
+     178         144 :                 OK (LAGraph_Cached_OutDegree (H, msg)) ;
+     179         144 :                 result = LAGraph_Cached_InDegree (H, msg) ;
+     180         144 :                 TEST_CHECK (result == ok_result) ;
+     181         144 :                 OK (LAGraph_Cached_IsSymmetricStructure (H, msg)) ;
+     182         144 :                 TEST_CHECK (G->is_symmetric_structure ==
+     183             :                             H->is_symmetric_structure) ;
+     184         144 :                 printf ("\nTrial %d, graph H, sorted (%s) by (%s) degrees:\n",
+     185             :                     trial, ascending ? "ascending" : "descending",
+     186             :                     byout ? "row" : "column") ;
+     187         144 :                 OK (LAGraph_Graph_Print (H, LAGraph_SHORT, stdout, msg)) ;
+     188             : 
+     189          72 :                 d = (byout || G->is_symmetric_structure == LAGraph_TRUE) ?
+     190         216 :                     H->out_degree : H->in_degree ;
+     191             : 
+     192             :                 // ensure d is sorted in ascending or descending order
+     193         144 :                 int64_t last_deg = (ascending) ? (-1) : (n+1) ;
+     194        1736 :                 for (int k = 0 ; k < n ; k++)
+     195             :                 {
+     196        1592 :                     int64_t deg = 0 ;
+     197        1592 :                     GrB_Info info = GrB_Vector_extractElement (&deg, d, k) ;
+     198        1592 :                     TEST_CHECK (info == GrB_NO_VALUE || info == GrB_SUCCESS) ;
+     199        1592 :                     if (info == GrB_NO_VALUE) deg = 0 ;
+     200        1592 :                     if (ascending)
+     201             :                     {
+     202         796 :                         TEST_CHECK (last_deg <= deg) ;
+     203             :                     }
+     204             :                     else
+     205             :                     {
+     206         796 :                         TEST_CHECK (last_deg >= deg) ;
+     207             :                     }
+     208        1592 :                     last_deg = deg ;
+     209             :                 }
+     210             : 
+     211             :                 // free workspace and the graph H
+     212         144 :                 OK (LAGraph_Free ((void **) &W, NULL)) ;
+     213         144 :                 OK (LAGraph_Free ((void **) &P, NULL)) ;
+     214         144 :                 OK (LAGraph_Delete (&H, msg)) ;
+     215             :             }
+     216             : 
+     217             :             // check if the adjacency matrix is symmetric
+     218          36 :             if (outer == 0)
+     219             :             {
+     220             :                 // if G->A is symmetric, then continue the outer iteration to
+     221             :                 // create an undirected graph.  Otherwise just do the directed
+     222             :                 // graph
+     223          25 :                 OK (LAGraph_Matrix_IsEqual (&is_symmetric, G->A, G->AT, msg)) ;
+     224          25 :                 if (!is_symmetric)
+     225             :                 {
+     226          14 :                     printf ("matrix is unsymmetric; skip undirected case\n") ;
+     227          14 :                     OK (LAGraph_Delete (&G, msg)) ;
+     228          14 :                     break ;
+     229             :                 }
+     230             :             }
+     231          22 :             OK (LAGraph_Delete (&G, msg)) ;
+     232             :         }
+     233             :     }
+     234             : 
+     235           1 :     teardown ( ) ;
+     236           1 : }
+     237             : 
+     238             : 
+     239             : //------------------------------------------------------------------------------
+     240             : // test_SortByDegree_brutal
+     241             : //------------------------------------------------------------------------------
+     242             : 
+     243             : #if LAGRAPH_SUITESPARSE
+     244           1 : void test_SortByDegree_brutal (void)
+     245             : {
+     246           1 :     OK (LG_brutal_setup (msg)) ;
+     247           1 :     printf ("\n") ;
+     248             : 
+     249           1 :     for (int kk = 0 ; ; kk++)
+     250          25 :     {
+     251             : 
+     252             :         // get the name of the test matrix
+     253          26 :         const char *aname = files [kk] ;
+     254          26 :         if (strlen (aname) == 0) break;
+     255          25 :         TEST_CASE (aname) ;
+     256          25 :         printf ("%s\n", aname) ;
+     257          25 :         snprintf (filename, LEN, LG_DATA_DIR "%s", aname) ;
+     258             : 
+     259          47 :         for (int outer = 0 ; outer <= 1 ; outer++)
+     260             :         {
+     261             : 
+     262             :             // load the matrix as A
+     263          36 :             FILE *f = fopen (filename, "r") ;
+     264          36 :             TEST_CHECK (f != NULL) ;
+     265          36 :             OK (LAGraph_MMRead (&A, f, msg)) ;
+     266          36 :             OK (fclose (f)) ;
+     267          36 :             TEST_MSG ("Loading of adjacency matrix failed") ;
+     268             : 
+     269             :             // ensure the matrix is square
+     270          36 :             OK (GrB_Matrix_nrows (&nrows, A)) ;
+     271          36 :             OK (GrB_Matrix_ncols (&ncols, A)) ;
+     272          36 :             TEST_CHECK (nrows == ncols) ;
+     273          36 :             n = nrows ;
+     274             : 
+     275             :             // decide if the graph G is directed or undirected
+     276          36 :             if (outer == 0)
+     277             :             {
+     278          25 :                 kind = LAGraph_ADJACENCY_DIRECTED ;
+     279             :             }
+     280             :             else
+     281             :             {
+     282          11 :                 kind = LAGraph_ADJACENCY_UNDIRECTED ;
+     283             :             }
+     284             : 
+     285             :             // construct a graph G with adjacency matrix A
+     286          36 :             TEST_CHECK (A != NULL) ;
+     287          36 :             OK (LAGraph_New (&G, &A, kind, msg)) ;
+     288          36 :             TEST_CHECK (A == NULL) ;
+     289          36 :             TEST_CHECK (G != NULL) ;
+     290             : 
+     291             :             // create the cached properties
+     292          72 :             int ok_result = (kind == LAGraph_ADJACENCY_UNDIRECTED) ?
+     293          36 :                 LAGRAPH_CACHE_NOT_NEEDED : GrB_SUCCESS ;
+     294          36 :             int result = LAGraph_Cached_AT (G, msg) ;
+     295          36 :             TEST_CHECK (result == ok_result) ;
+     296          36 :             OK (LAGraph_Cached_OutDegree (G, msg)) ;
+     297          36 :             result = LAGraph_Cached_InDegree (G, msg) ;
+     298          36 :             TEST_CHECK (result == ok_result) ;
+     299          36 :             OK (LAGraph_Cached_IsSymmetricStructure (G, msg)) ;
+     300             :             // OK (LAGraph_Graph_Print (G, LAGraph_SHORT, stdout, msg)) ;
+     301             : 
+     302             :             // sort 4 different ways
+     303         180 :             for (int trial = 0 ; trial <= 3 ; trial++)
+     304             :             {
+     305         144 :                 bool byout = (trial == 0 || trial == 1) ;
+     306         144 :                 bool ascending = (trial == 0 || trial == 2) ;
+     307             : 
+     308             :                 // sort the graph by degree
+     309         144 :                 TEST_CHECK (P == NULL) ;
+     310         144 :                 OK (LAGr_SortByDegree (&P, G, byout, ascending, msg)) ;
+     311         144 :                 TEST_CHECK (P != NULL) ;
+     312             : 
+     313             :                 // ensure P is a permutation of 0..n-1
+     314         144 :                 OK (LAGraph_Calloc ((void **) &W, n, sizeof (bool), msg)) ;
+     315        1736 :                 for (int k = 0 ; k < n ; k++)
+     316             :                 {
+     317        1592 :                     int64_t j = P [k] ;
+     318        1592 :                     TEST_CHECK (j >= 0 && j < n) ;
+     319        1592 :                     TEST_CHECK (W [j] == false) ;
+     320        1592 :                     W [j] = true ;
+     321             :                 }
+     322             : 
+     323             :                 // check the result by constructing a new graph with adjacency
+     324             :                 // matrix B = A (P,P)
+     325         144 :                 OK (GrB_Matrix_new (&B, GrB_BOOL, n, n)) ;
+     326         144 :                 OK (GrB_extract (B, NULL, NULL, G->A,
+     327             :                     (GrB_Index *) P, n, (GrB_Index *) P, n, NULL)) ;
+     328         144 :                 OK (LAGraph_New (&H, &B, kind, msg)) ;
+     329         144 :                 TEST_CHECK (B == NULL) ;
+     330         144 :                 TEST_CHECK (H != NULL) ;
+     331             : 
+     332             :                 // get the cached properties of H
+     333         144 :                 OK (LAGraph_Cached_OutDegree (H, msg)) ;
+     334         144 :                 result = LAGraph_Cached_InDegree (H, msg) ;
+     335         144 :                 TEST_CHECK (result == ok_result) ;
+     336         144 :                 OK (LAGraph_Cached_IsSymmetricStructure (H, msg)) ;
+     337         144 :                 TEST_CHECK (G->is_symmetric_structure ==
+     338             :                             H->is_symmetric_structure) ;
+     339             : 
+     340          72 :                 d = (byout || G->is_symmetric_structure == LAGraph_TRUE) ?
+     341         216 :                     H->out_degree : H->in_degree ;
+     342             : 
+     343             :                 // ensure d is sorted in ascending or descending order
+     344         144 :                 int64_t last_deg = (ascending) ? (-1) : (n+1) ;
+     345        1736 :                 for (int k = 0 ; k < n ; k++)
+     346             :                 {
+     347        1592 :                     int64_t deg = 0 ;
+     348        1592 :                     GrB_Info info = GrB_Vector_extractElement (&deg, d, k) ;
+     349        1592 :                     TEST_CHECK (info == GrB_NO_VALUE || info == GrB_SUCCESS) ;
+     350        1592 :                     if (info == GrB_NO_VALUE) deg = 0 ;
+     351        1592 :                     if (ascending)
+     352             :                     {
+     353         796 :                         TEST_CHECK (last_deg <= deg) ;
+     354             :                     }
+     355             :                     else
+     356             :                     {
+     357         796 :                         TEST_CHECK (last_deg >= deg) ;
+     358             :                     }
+     359        1592 :                     last_deg = deg ;
+     360             :                 }
+     361             : 
+     362             :                 // free workspace and the graph H
+     363         144 :                 OK (LAGraph_Free ((void **) &W, NULL)) ;
+     364         144 :                 OK (LAGraph_Free ((void **) &P, NULL)) ;
+     365         144 :                 OK (LAGraph_Delete (&H, msg)) ;
+     366             :             }
+     367             : 
+     368             :             // check if the adjacency matrix is symmetric
+     369          36 :             if (outer == 0)
+     370             :             {
+     371             :                 // if G->A is symmetric, then continue the outer iteration to
+     372             :                 // create an undirected graph.  Otherwise just do the directed
+     373             :                 // graph
+     374          25 :                 OK (LAGraph_Matrix_IsEqual (&is_symmetric, G->A, G->AT, msg)) ;
+     375          25 :                 if (!is_symmetric)
+     376             :                 {
+     377          14 :                     OK (LAGraph_Delete (&G, msg)) ;
+     378          14 :                     break ;
+     379             :                 }
+     380             :             }
+     381             : 
+     382          22 :             OK (LAGraph_Delete (&G, msg)) ;
+     383             :         }
+     384             :     }
+     385             : 
+     386           1 :     OK (LG_brutal_teardown (msg)) ;
+     387           1 : }
+     388             : #endif
+     389             : 
+     390             : //-----------------------------------------------------------------------------
+     391             : // test_SortByDegree_failures:  test error handling of LAGr_SortByDegree
+     392             : //-----------------------------------------------------------------------------
+     393             : 
+     394           1 : void test_SortByDegree_failures (void)
+     395             : {
+     396           1 :     setup ( ) ;
+     397             : 
+     398           1 :     int result = LAGr_SortByDegree (NULL, NULL, true, true, msg) ;
+     399           1 :     printf ("\nresult %d: msg: %s\n", result, msg) ;
+     400           1 :     TEST_CHECK (result == GrB_NULL_POINTER) ;
+     401             : 
+     402           1 :     result = LAGr_SortByDegree (&P, NULL, true, true, msg) ;
+     403           1 :     TEST_CHECK (result == GrB_NULL_POINTER) ;
+     404           1 :     printf ("msg: %s\n", msg) ;
+     405             : 
+     406             :     // create the karate graph
+     407           1 :     FILE *f = fopen (LG_DATA_DIR "karate.mtx", "r") ;
+     408           1 :     TEST_CHECK (f != NULL) ;
+     409           1 :     OK (LAGraph_MMRead (&A, f, msg)) ;
+     410           1 :     OK (fclose (f)) ;
+     411           1 :     TEST_MSG ("Loading of adjacency matrix failed") ;
+     412           1 :     OK (LAGraph_New (&G, &A, LAGraph_ADJACENCY_UNDIRECTED, msg)) ;
+     413             : 
+     414             :     // cached degree property must first be computed
+     415           1 :     result = LAGr_SortByDegree (&P, G, true, true, msg) ;
+     416           1 :     printf ("\nresult %d: msg: %s\n", result, msg) ;
+     417           1 :     TEST_CHECK (result == LAGRAPH_NOT_CACHED) ;
+     418             : 
+     419           1 :     teardown ( ) ;
+     420           1 : }
+     421             : 
+     422             : //-----------------------------------------------------------------------------
+     423             : // TEST_LIST: the list of tasks for this entire test
+     424             : //-----------------------------------------------------------------------------
+     425             : 
+     426             : TEST_LIST =
+     427             : {
+     428             :     { "SortByDegree", test_SortByDegree },
+     429             :     { "SortByDegree_failures", test_SortByDegree_failures },
+     430             :     #if LAGRAPH_SUITESPARSE
+     431             :     { "SortByDegree_brutal", test_SortByDegree_brutal },
+     432             :     #endif
+     433             :     { NULL, NULL }
+     434             : } ;
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_TriangleCount.c.func-sort-c.html b/src/test/test_TriangleCount.c.func-sort-c.html new file mode 100644 index 0000000000..e7d8b5aace --- /dev/null +++ b/src/test/test_TriangleCount.c.func-sort-c.html @@ -0,0 +1,120 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_TriangleCount.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_TriangleCount.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:255255100.0 %
Date:2024-08-29 20:08:04Functions:1212100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_TriangleCount1
test_TriangleCount_Methods11
test_TriangleCount_Methods21
test_TriangleCount_Methods31
test_TriangleCount_Methods41
test_TriangleCount_Methods51
test_TriangleCount_Methods61
test_TriangleCount_autosort1
test_TriangleCount_brutal1
test_TriangleCount_many1
setup7
teardown7
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_TriangleCount.c.func.html b/src/test/test_TriangleCount.c.func.html new file mode 100644 index 0000000000..2007d98eb9 --- /dev/null +++ b/src/test/test_TriangleCount.c.func.html @@ -0,0 +1,120 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_TriangleCount.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_TriangleCount.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:255255100.0 %
Date:2024-08-29 20:08:04Functions:1212100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
setup7
teardown7
test_TriangleCount1
test_TriangleCount_Methods11
test_TriangleCount_Methods21
test_TriangleCount_Methods31
test_TriangleCount_Methods41
test_TriangleCount_Methods51
test_TriangleCount_Methods61
test_TriangleCount_autosort1
test_TriangleCount_brutal1
test_TriangleCount_many1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_TriangleCount.c.gcov.html b/src/test/test_TriangleCount.c.gcov.html new file mode 100644 index 0000000000..a3122965da --- /dev/null +++ b/src/test/test_TriangleCount.c.gcov.html @@ -0,0 +1,566 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_TriangleCount.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_TriangleCount.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:255255100.0 %
Date:2024-08-29 20:08:04Functions:1212100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //----------------------------------------------------------------------------
+       2             : // LAGraph/src/test/test_TriangleCount.c: test cases for triangle
+       3             : // counting algorithms
+       4             : // ----------------------------------------------------------------------------
+       5             : 
+       6             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       7             : // SPDX-License-Identifier: BSD-2-Clause
+       8             : //
+       9             : // For additional details (including references to third party source code and
+      10             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      11             : // Contributors.txt for a full list of contributors. Created, in part, with
+      12             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      13             : // DM22-0790
+      14             : 
+      15             : // Contributed by Scott McMillan, SEI, and Timothy A. Davis, Texas A&M
+      16             : // University
+      17             : 
+      18             : //-----------------------------------------------------------------------------
+      19             : 
+      20             : #include <stdio.h>
+      21             : #include <acutest.h>
+      22             : 
+      23             : #include <LAGraph_test.h>
+      24             : #include <graph_zachary_karate.h>
+      25             : 
+      26             : char msg[LAGRAPH_MSG_LEN];
+      27             : LAGraph_Graph G = NULL;
+      28             : 
+      29             : #define LEN 512
+      30             : char filename [LEN+1] ;
+      31             : 
+      32             : typedef struct
+      33             : {
+      34             :     uint64_t ntriangles ;           // # triangles in original matrix
+      35             :     const char *name ;              // matrix filename
+      36             : }
+      37             : matrix_info ;
+      38             : 
+      39             : const matrix_info files [ ] =
+      40             : {
+      41             :     {     45, "karate.mtx" },
+      42             :     {     11, "A.mtx" },
+      43             :     {   2016, "jagmesh7.mtx" },
+      44             :     {      6, "ldbc-cdlp-undirected-example.mtx" },
+      45             :     {      4, "ldbc-undirected-example.mtx" },
+      46             :     {      5, "ldbc-wcc-example.mtx" },
+      47             :     {      0, "LFAT5.mtx" },
+      48             :     { 342300, "bcsstk13.mtx" },
+      49             :     {      0, "tree-example.mtx" },
+      50             :     {      0, "" },
+      51             : } ;
+      52             : 
+      53             : //****************************************************************************
+      54           7 : void setup(void)
+      55             : {
+      56           7 :     LAGraph_Init(msg);
+      57             :     int retval;
+      58             : 
+      59           7 :     GrB_Matrix A = NULL;
+      60             : 
+      61           7 :     GrB_Matrix_new(&A, GrB_UINT32, ZACHARY_NUM_NODES, ZACHARY_NUM_NODES);
+      62           7 :     GrB_Matrix_build(A, ZACHARY_I, ZACHARY_J, ZACHARY_V, ZACHARY_NUM_EDGES,
+      63             :                      GrB_LOR);
+      64             : 
+      65           7 :     retval = LAGraph_New(&G, &A, LAGraph_ADJACENCY_UNDIRECTED, msg);
+      66           7 :     TEST_CHECK(retval == 0);
+      67           7 :     TEST_MSG("retval = %d (%s)", retval, msg);
+      68             : 
+      69           7 :     retval = LAGraph_Cached_NSelfEdges(G, msg);
+      70           7 :     TEST_CHECK(retval == 0);
+      71           7 :     TEST_MSG("retval = %d (%s)", retval, msg);
+      72             : 
+      73           7 :     TEST_CHECK(G->nself_edges == 0);
+      74           7 : }
+      75             : 
+      76             : //****************************************************************************
+      77           7 : void teardown(void)
+      78             : {
+      79           7 :     int retval = LAGraph_Delete(&G, msg);
+      80           7 :     TEST_CHECK(retval == 0);
+      81           7 :     TEST_MSG("retval = %d (%s)", retval, msg);
+      82             : 
+      83           7 :     G = NULL;
+      84           7 :     LAGraph_Finalize(msg);
+      85           7 : }
+      86             : 
+      87             : //****************************************************************************
+      88             : //****************************************************************************
+      89           1 : void test_TriangleCount_Methods1(void)
+      90             : {
+      91           1 :     setup();
+      92             :     int retval;
+      93           1 :     uint64_t ntriangles = 0UL;
+      94             : 
+      95             :     // with presort
+      96           1 :     LAGr_TriangleCount_Presort presort = LAGr_TriangleCount_AutoSort ;
+      97           1 :     LAGr_TriangleCount_Method method = LAGr_TriangleCount_Burkhardt ;
+      98           1 :     ntriangles = 0UL;
+      99             :     // LAGr_TriangleCount_Burkhardt: sum (sum ((A^2) .* A)) / 6
+     100           1 :     retval = LAGr_TriangleCount(&ntriangles, G, &method, &presort, msg);
+     101             : 
+     102           1 :     TEST_CHECK(retval == 0);
+     103           1 :     TEST_MSG("retval = %d (%s)", retval, msg);
+     104             : 
+     105           1 :     TEST_CHECK( ntriangles == 45 );
+     106           1 :     TEST_MSG("numtri = %g", (double) ntriangles);
+     107             : 
+     108           1 :     teardown();
+     109           1 : }
+     110             : 
+     111             : //****************************************************************************
+     112           1 : void test_TriangleCount_Methods2(void)
+     113             : {
+     114           1 :     setup();
+     115             :     int retval;
+     116           1 :     uint64_t ntriangles = 0UL;
+     117             : 
+     118           1 :     LAGr_TriangleCount_Presort presort = LAGr_TriangleCount_AutoSort ;
+     119           1 :     LAGr_TriangleCount_Method method = LAGr_TriangleCount_Cohen ;
+     120           1 :     ntriangles = 0UL;
+     121             :     // LAGr_TriangleCount_Cohen: sum (sum ((L * U) .* A)) / 2
+     122           1 :     retval = LAGr_TriangleCount(&ntriangles, G, &method, &presort, msg);
+     123           1 :     TEST_CHECK(retval == 0);
+     124           1 :     TEST_MSG("retval = %d (%s)", retval, msg);
+     125             : 
+     126           1 :     TEST_CHECK( ntriangles == 45 );
+     127           1 :     TEST_MSG("numtri = %g", (double) ntriangles);
+     128             : 
+     129           1 :     teardown();
+     130           1 : }
+     131             : 
+     132             : //****************************************************************************
+     133           1 : void test_TriangleCount_Methods3(void)
+     134             : {
+     135           1 :     setup();
+     136             :     int retval;
+     137           1 :     uint64_t ntriangles = 0UL;
+     138             : 
+     139           1 :     LAGr_TriangleCount_Presort presort = LAGr_TriangleCount_AutoSort ;
+     140           1 :     LAGr_TriangleCount_Method method = LAGr_TriangleCount_Sandia_LL ;
+     141           1 :     ntriangles = 0UL;
+     142             :     // LAGr_TriangleCount_Sandia_LL: sum (sum ((L * L) .* L))
+     143           1 :     retval = LAGr_TriangleCount (&ntriangles, G, &method, &presort, msg) ;
+     144             :     // should fail (out_degrees needs to be defined)
+     145           1 :     TEST_CHECK(retval == LAGRAPH_NOT_CACHED);
+     146           1 :     TEST_MSG("retval = %d (%s)", retval, msg);
+     147             : 
+     148           1 :     retval = LAGraph_Cached_OutDegree(G, msg);
+     149           1 :     TEST_CHECK(retval == 0);
+     150           1 :     TEST_MSG("retval = %d (%s)", retval, msg);
+     151             : 
+     152           1 :     presort = LAGr_TriangleCount_AutoSort ;
+     153           1 :     method = LAGr_TriangleCount_Sandia_LL ;
+     154           1 :     retval = LAGr_TriangleCount(&ntriangles, G, &method, &presort, msg);
+     155           1 :     TEST_CHECK(retval == 0);
+     156           1 :     TEST_MSG("retval = %d (%s)", retval, msg);
+     157             : 
+     158           1 :     TEST_CHECK( ntriangles == 45 );
+     159           1 :     TEST_MSG("numtri = %g", (double) ntriangles);
+     160             : 
+     161           1 :     teardown();
+     162           1 : }
+     163             : 
+     164             : //****************************************************************************
+     165           1 : void test_TriangleCount_Methods4(void)
+     166             : {
+     167           1 :     setup();
+     168             :     int retval;
+     169           1 :     uint64_t ntriangles = 0UL;
+     170             : 
+     171           1 :     LAGr_TriangleCount_Presort presort = LAGr_TriangleCount_AutoSort ;
+     172           1 :     LAGr_TriangleCount_Method method = LAGr_TriangleCount_Sandia_UU ;
+     173           1 :     ntriangles = 0UL;
+     174             :     // LAGr_TriangleCount_Sandia_UU: sum (sum ((U * U) .* U))
+     175           1 :     retval = LAGr_TriangleCount(&ntriangles, G, &method, &presort, msg);
+     176             :     // should fail (out_degrees needs to be defined)
+     177           1 :     TEST_CHECK(retval == LAGRAPH_NOT_CACHED);
+     178           1 :     TEST_MSG("retval = %d (%s)", retval, msg);
+     179             : 
+     180           1 :     retval = LAGraph_Cached_OutDegree(G, msg);
+     181           1 :     TEST_CHECK(retval == 0);
+     182           1 :     TEST_MSG("retval = %d (%s)", retval, msg);
+     183             : 
+     184           1 :     presort = LAGr_TriangleCount_AutoSort ;
+     185           1 :     method = LAGr_TriangleCount_Sandia_UU ;
+     186           1 :     retval = LAGr_TriangleCount(&ntriangles, G, &method, &presort, msg);
+     187           1 :     TEST_CHECK(retval == 0);
+     188           1 :     TEST_MSG("retval = %d (%s)", retval, msg);
+     189             : 
+     190           1 :     TEST_CHECK( ntriangles == 45 );
+     191           1 :     TEST_MSG("numtri = %g", (double) ntriangles) ;
+     192             : 
+     193           1 :     teardown();
+     194           1 : }
+     195             : 
+     196             : //****************************************************************************
+     197           1 : void test_TriangleCount_Methods5(void)
+     198             : {
+     199           1 :     setup();
+     200             :     int retval;
+     201           1 :     uint64_t ntriangles = 0UL;
+     202             : 
+     203           1 :     LAGr_TriangleCount_Presort presort = LAGr_TriangleCount_AutoSort ;
+     204           1 :     LAGr_TriangleCount_Method method = LAGr_TriangleCount_Sandia_LUT ;
+     205           1 :     ntriangles = 0UL;
+     206             :     // LAGr_TriangleCount_Sandia_LUT: sum (sum ((L * U') .* L))
+     207           1 :     retval = LAGr_TriangleCount(&ntriangles, G, &method, &presort, msg);
+     208             :     // should fail (out_degrees needs to be defined)
+     209           1 :     TEST_CHECK(retval == LAGRAPH_NOT_CACHED);
+     210           1 :     TEST_MSG("retval = %d (%s)", retval, msg);
+     211             : 
+     212           1 :     retval = LAGraph_Cached_OutDegree(G, msg);
+     213           1 :     TEST_CHECK(retval == 0);
+     214           1 :     TEST_MSG("retval = %d (%s)", retval, msg);
+     215             : 
+     216           1 :     presort = LAGr_TriangleCount_AutoSort ;
+     217           1 :     method = LAGr_TriangleCount_Sandia_LUT ;
+     218           1 :     retval = LAGr_TriangleCount(&ntriangles, G, &method, &presort, msg);
+     219           1 :     TEST_CHECK(retval == 0);
+     220           1 :     TEST_MSG("retval = %d (%s)", retval, msg);
+     221             : 
+     222           1 :     TEST_CHECK( ntriangles == 45 );
+     223           1 :     TEST_MSG("numtri = %g", (double) ntriangles) ;
+     224             : 
+     225           1 :     teardown();
+     226           1 : }
+     227             : 
+     228             : //****************************************************************************
+     229           1 : void test_TriangleCount_Methods6(void)
+     230             : {
+     231           1 :     setup();
+     232             :     int retval;
+     233           1 :     uint64_t ntriangles = 0UL;
+     234             : 
+     235           1 :     LAGr_TriangleCount_Presort presort = LAGr_TriangleCount_AutoSort ;
+     236           1 :     LAGr_TriangleCount_Method method = LAGr_TriangleCount_Sandia_ULT ;
+     237           1 :     ntriangles = 0UL;
+     238             :     // LAGr_TriangleCount_Sandia_ULT: sum (sum ((U * L') .* U))
+     239           1 :     retval = LAGr_TriangleCount(&ntriangles, G, &method, &presort, msg);
+     240             :     // should fail (out_degrees needs to be defined)
+     241           1 :     TEST_CHECK(retval == LAGRAPH_NOT_CACHED) ;
+     242           1 :     TEST_MSG("retval = %d (%s)", retval, msg);
+     243             : 
+     244           1 :     retval = LAGraph_Cached_OutDegree(G, msg);
+     245           1 :     TEST_CHECK(retval == 0);
+     246           1 :     TEST_MSG("retval = %d (%s)", retval, msg);
+     247             : 
+     248           1 :     presort = LAGr_TriangleCount_AutoSort ;
+     249           1 :     method = LAGr_TriangleCount_Sandia_ULT ;
+     250           1 :     retval = LAGr_TriangleCount(&ntriangles, G, &method, &presort, msg);
+     251           1 :     TEST_CHECK(retval == 0);
+     252           1 :     TEST_MSG("retval = %d (%s)", retval, msg);
+     253             : 
+     254           1 :     TEST_CHECK( ntriangles == 45 );
+     255           1 :     TEST_MSG("numtri = %g", (double) ntriangles) ;
+     256             : 
+     257           1 :     teardown();
+     258           1 : }
+     259             : 
+     260             : //****************************************************************************
+     261           1 : void test_TriangleCount(void)
+     262             : {
+     263           1 :     setup();
+     264             : 
+     265           1 :     uint64_t ntriangles = 0UL;
+     266           1 :     int retval = LAGraph_TriangleCount(&ntriangles, G, msg);
+     267             :     // should not fail (out_degrees will be calculated)
+     268           1 :     TEST_CHECK(retval == 0);
+     269           1 :     TEST_MSG("retval = %d (%s)", retval, msg);
+     270             : 
+     271           1 :     TEST_CHECK( ntriangles == 45 );
+     272           1 :     TEST_MSG("numtri = %g", (double) ntriangles) ;
+     273             : 
+     274           1 :     OK (LG_check_tri (&ntriangles, G, msg)) ;
+     275           1 :     TEST_CHECK( ntriangles == 45 );
+     276             : 
+     277           1 :     teardown();
+     278           1 : }
+     279             : 
+     280             : //****************************************************************************
+     281           1 : void test_TriangleCount_many (void)
+     282             : {
+     283           1 :     LAGraph_Init(msg);
+     284           1 :     GrB_Matrix A = NULL ;
+     285           1 :     printf ("\n") ;
+     286             : 
+     287           1 :     for (int k = 0 ; ; k++)
+     288           9 :     {
+     289             : 
+     290             :         // load the adjacency matrix as A
+     291          10 :         const char *aname = files [k].name ;
+     292          10 :         uint64_t ntriangles = files [k].ntriangles ;
+     293          10 :         if (strlen (aname) == 0) break;
+     294           9 :         TEST_CASE (aname) ;
+     295           9 :         snprintf (filename, LEN, LG_DATA_DIR "%s", aname) ;
+     296           9 :         FILE *f = fopen (filename, "r") ;
+     297           9 :         TEST_CHECK (f != NULL) ;
+     298           9 :         OK (LAGraph_MMRead (&A, f, msg)) ;
+     299           9 :         OK (fclose (f)) ;
+     300           9 :         TEST_MSG ("Loading of adjacency matrix failed") ;
+     301             : 
+     302             :         // create the graph
+     303           9 :         OK (LAGraph_New (&G, &A, LAGraph_ADJACENCY_UNDIRECTED, msg)) ;
+     304           9 :         TEST_CHECK (A == NULL) ;    // A has been moved into G->A
+     305             : 
+     306             :         // delete any diagonal entries
+     307           9 :         OK (LAGraph_DeleteSelfEdges (G, msg)) ;
+     308           9 :         TEST_CHECK (G->nself_edges == 0) ;
+     309           9 :         OK (LAGraph_DeleteSelfEdges (G, msg)) ;
+     310           9 :         TEST_CHECK (G->nself_edges == 0) ;
+     311             : 
+     312             :         // get the # of triangles
+     313             :         uint64_t nt0, nt1 ;
+     314           9 :         OK (LAGraph_TriangleCount (&nt1, G, msg)) ;
+     315           9 :         printf ("# triangles: %g Matrix: %s\n", (double) nt1, aname) ;
+     316           9 :         TEST_CHECK (nt1 == ntriangles) ;
+     317           9 :         OK (LG_check_tri (&nt0, G, msg)) ;
+     318           9 :         TEST_CHECK (nt0 == nt1) ;
+     319             : 
+     320             :         // convert to directed but with symmetric pattern
+     321           9 :         G->kind = LAGraph_ADJACENCY_DIRECTED ;
+     322           9 :         G->is_symmetric_structure = LAGraph_TRUE ;
+     323           9 :         OK (LAGraph_TriangleCount (&nt1, G, msg)) ;
+     324           9 :         TEST_CHECK (nt1 == ntriangles) ;
+     325             : 
+     326           9 :         OK (LG_check_tri (&nt0, G, msg)) ;
+     327           9 :         TEST_CHECK (nt0 == nt1) ;
+     328             : 
+     329             :         // try each method
+     330          72 :         for (int method = 0 ; method <= 6 ; method++)
+     331             :         {
+     332         252 :             for (int presort = 0 ; presort <= 2 ; presort++)
+     333             :             {
+     334         189 :                 LAGr_TriangleCount_Presort s = presort ;
+     335         189 :                 LAGr_TriangleCount_Method m = method ;
+     336         189 :                 OK (LAGr_TriangleCount (&nt1, G, &m, &s, msg)) ;
+     337         189 :                 TEST_CHECK (nt1 == ntriangles) ;
+     338             :             }
+     339             :         }
+     340             : 
+     341             :         // invalid method
+     342           9 :         LAGr_TriangleCount_Method method = 99 ;
+     343           9 :         int result = LAGr_TriangleCount (&nt1, G, &method, NULL, msg) ;
+     344           9 :         TEST_CHECK (result == GrB_INVALID_VALUE) ;
+     345           9 :         LAGr_TriangleCount_Presort presort = 99 ;
+     346           9 :         result = LAGr_TriangleCount (&nt1, G, NULL, &presort, msg) ;
+     347           9 :         TEST_CHECK (result == GrB_INVALID_VALUE) ;
+     348             : 
+     349           9 :         OK (LAGraph_Delete (&G, msg)) ;
+     350             :     }
+     351             : 
+     352           1 :     LAGraph_Finalize(msg);
+     353           1 : }
+     354             : 
+     355             : //****************************************************************************
+     356             : 
+     357           1 : void test_TriangleCount_autosort (void)
+     358             : {
+     359           1 :     OK (LAGraph_Init(msg)) ;
+     360             : 
+     361             :     // create a banded matrix with a some dense rows/columns
+     362           1 :     GrB_Index n = 50000 ;
+     363           1 :     GrB_Matrix A = NULL ;
+     364           1 :     OK (GrB_Matrix_new (&A, GrB_BOOL, n, n)) ;
+     365             : 
+     366          12 :     for (int k = 0 ; k <= 10 ; k++)
+     367             :     {
+     368      550011 :         for (int i = 0 ; i < n ; i++)
+     369             :         {
+     370      550000 :             OK (GrB_Matrix_setElement_BOOL (A, true, i, k)) ;
+     371      550000 :             OK (GrB_Matrix_setElement_BOOL (A, true, k, i)) ;
+     372             :         }
+     373             :     }
+     374             : 
+     375             :     // create the graph
+     376           1 :     OK (LAGraph_New (&G, &A, LAGraph_ADJACENCY_UNDIRECTED, msg)) ;
+     377           1 :     TEST_CHECK (A == NULL) ;    // A has been moved into G->A
+     378             : 
+     379           1 :     OK (LAGraph_DeleteSelfEdges (G, msg)) ;
+     380           1 :     TEST_CHECK (G->nself_edges == 0) ;
+     381             : 
+     382           1 :     OK (LAGraph_Cached_OutDegree (G, msg)) ;
+     383             : 
+     384             :     // try each method; with autosort
+     385           1 :     GrB_Index nt1 = 0 ;
+     386           8 :     for (int method = 0 ; method <= 6 ; method++)
+     387             :     {
+     388           7 :         LAGr_TriangleCount_Presort presort = LAGr_TriangleCount_AutoSort ;
+     389           7 :         LAGr_TriangleCount_Method m = method ;
+     390           7 :         nt1 = 0 ;
+     391           7 :         OK (LAGr_TriangleCount (&nt1, G, &m, &presort, msg)) ;
+     392           7 :         TEST_CHECK (nt1 == 2749560) ;
+     393             :     }
+     394             : 
+     395           1 :     nt1 = 0 ;
+     396           1 :     OK (LAGraph_TriangleCount (&nt1, G, msg)) ;
+     397           1 :     TEST_CHECK (nt1 == 2749560) ;
+     398             : 
+     399           1 :     OK (LAGraph_Finalize(msg)) ;
+     400           1 : }
+     401             : 
+     402             : //------------------------------------------------------------------------------
+     403             : // test_TriangleCount_brutal
+     404             : //------------------------------------------------------------------------------
+     405             : 
+     406             : #if LAGRAPH_SUITESPARSE
+     407           1 : void test_TriangleCount_brutal (void)
+     408             : {
+     409           1 :     OK (LG_brutal_setup (msg)) ;
+     410             : 
+     411           1 :     GrB_Matrix A = NULL ;
+     412           1 :     printf ("\n") ;
+     413             : 
+     414           1 :     for (int k = 0 ; ; k++)
+     415           9 :     {
+     416             : 
+     417             :         // load the adjacency matrix as A
+     418          10 :         const char *aname = files [k].name ;
+     419          10 :         uint64_t ntriangles = files [k].ntriangles ;
+     420          10 :         if (strlen (aname) == 0) break;
+     421           9 :         printf ("\n================== Matrix: %s\n", aname) ;
+     422           9 :         TEST_CASE (aname) ;
+     423           9 :         snprintf (filename, LEN, LG_DATA_DIR "%s", aname) ;
+     424           9 :         FILE *f = fopen (filename, "r") ;
+     425           9 :         TEST_CHECK (f != NULL) ;
+     426           9 :         OK (LAGraph_MMRead (&A, f, msg)) ;
+     427           9 :         OK (fclose (f)) ;
+     428           9 :         TEST_MSG ("Loading of adjacency matrix failed") ;
+     429             : 
+     430             :         // create the graph
+     431           9 :         OK (LAGraph_New (&G, &A, LAGraph_ADJACENCY_UNDIRECTED, msg)) ;
+     432             : 
+     433             :         // delete any diagonal entries
+     434           9 :         OK (LAGraph_DeleteSelfEdges (G, msg)) ;
+     435             : 
+     436             :         // get the # of triangles
+     437             :         uint64_t nt0, nt1 ;
+     438         192 :         LG_BRUTAL_BURBLE (LAGraph_TriangleCount (&nt1, G, msg)) ;
+     439           9 :         printf ("# triangles: %g Matrix: %s\n", (double) nt1, aname) ;
+     440           9 :         TEST_CHECK (nt1 == ntriangles) ;
+     441             : 
+     442          62 :         LG_BRUTAL_BURBLE (LG_check_tri (&nt0, G, msg)) ;
+     443           9 :         TEST_CHECK (nt0 == nt1) ;
+     444             : 
+     445             :         // convert to directed but with symmetric pattern
+     446           9 :         G->kind = LAGraph_ADJACENCY_DIRECTED ;
+     447           9 :         G->is_symmetric_structure = LAGraph_TRUE ;
+     448         192 :         LG_BRUTAL (LAGraph_TriangleCount (&nt1, G, msg)) ;
+     449           9 :         TEST_CHECK (nt1 == ntriangles) ;
+     450             : 
+     451          62 :         LG_BRUTAL_BURBLE (LG_check_tri (&nt0, G, msg)) ;
+     452           9 :         TEST_CHECK (nt0 == nt1) ;
+     453             : 
+     454             :         // try each method
+     455          72 :         for (int method = 0 ; method <= 6 ; method++)
+     456             :         {
+     457         252 :             for (int presort = 0 ; presort <= 2 ; presort++)
+     458             :             {
+     459         189 :                 LAGr_TriangleCount_Presort s = presort ;
+     460         189 :                 LAGr_TriangleCount_Method m = method ;
+     461        3833 :                 LG_BRUTAL_BURBLE (LAGr_TriangleCount (&nt1, G, &m, &s, msg)) ;
+     462         189 :                 TEST_CHECK (nt1 == ntriangles) ;
+     463             :             }
+     464             :         }
+     465             : 
+     466           9 :         OK (LAGraph_Delete (&G, msg)) ;
+     467             :     }
+     468             : 
+     469           1 :     OK (LG_brutal_teardown (msg)) ;
+     470           1 : }
+     471             : #endif
+     472             : 
+     473             : 
+     474             : //****************************************************************************
+     475             : //****************************************************************************
+     476             : TEST_LIST = {
+     477             :     {"TriangleCount_Methods1", test_TriangleCount_Methods1},
+     478             :     {"TriangleCount_Methods2", test_TriangleCount_Methods2},
+     479             :     {"TriangleCount_Methods3", test_TriangleCount_Methods3},
+     480             :     {"TriangleCount_Methods4", test_TriangleCount_Methods4},
+     481             :     {"TriangleCount_Methods5", test_TriangleCount_Methods5},
+     482             :     {"TriangleCount_Methods6", test_TriangleCount_Methods6},
+     483             :     {"TriangleCount"         , test_TriangleCount},
+     484             :     {"TriangleCount_many"    , test_TriangleCount_many},
+     485             :     {"TriangleCount_autosort", test_TriangleCount_autosort},
+     486             :     #if LAGRAPH_SUITESPARSE
+     487             :     {"TriangleCount_brutal"  , test_TriangleCount_brutal},
+     488             :     #endif
+     489             :     {NULL, NULL}
+     490             : };
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_Type.c.func-sort-c.html b/src/test/test_Type.c.func-sort-c.html new file mode 100644 index 0000000000..a8ccbc4488 --- /dev/null +++ b/src/test/test_Type.c.func-sort-c.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_Type.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_Type.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:9494100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_TypeName1
test_TypeSize1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_Type.c.func.html b/src/test/test_Type.c.func.html new file mode 100644 index 0000000000..2bb2809474 --- /dev/null +++ b/src/test/test_Type.c.func.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_Type.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_Type.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:9494100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_TypeName1
test_TypeSize1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_Type.c.gcov.html b/src/test/test_Type.c.gcov.html new file mode 100644 index 0000000000..ae7f113e4b --- /dev/null +++ b/src/test/test_Type.c.gcov.html @@ -0,0 +1,263 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_Type.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_Type.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:9494100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph/src/test/test_Type.c:  test LAGraph_*Type* methods
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include "LAGraph_test.h"
+      19             : 
+      20             : //------------------------------------------------------------------------------
+      21             : // global variables
+      22             : //------------------------------------------------------------------------------
+      23             : 
+      24             : GrB_Type type = NULL ;
+      25             : char name [LAGRAPH_MAX_NAME_LEN] ;
+      26             : char msg [LAGRAPH_MSG_LEN] ;
+      27             : GrB_Scalar s = NULL ;
+      28             : 
+      29             : typedef int myint ;
+      30             : 
+      31             : //------------------------------------------------------------------------------
+      32             : // test_TypeName :  test LAGraph_NameOfType
+      33             : //------------------------------------------------------------------------------
+      34             : 
+      35           1 : void test_TypeName  (void)
+      36             : {
+      37           1 :     OK (LAGraph_Init (msg)) ;
+      38             : 
+      39           1 :     OK (LAGraph_NameOfType  (name, GrB_BOOL, msg)) ;
+      40           1 :     OK (strcmp (name, "bool")) ;
+      41             : 
+      42           1 :     OK (LAGraph_NameOfType  (name, GrB_INT8, msg)) ;
+      43           1 :     OK (strcmp (name, "int8_t")) ;
+      44             : 
+      45           1 :     OK (LAGraph_NameOfType  (name, GrB_INT16, msg)) ;
+      46           1 :     OK (strcmp (name, "int16_t")) ;
+      47             : 
+      48           1 :     OK (LAGraph_NameOfType  (name, GrB_INT32, msg)) ;
+      49           1 :     OK (strcmp (name, "int32_t")) ;
+      50             : 
+      51           1 :     OK (LAGraph_NameOfType  (name, GrB_INT64, msg)) ;
+      52           1 :     OK (strcmp (name, "int64_t")) ;
+      53             : 
+      54           1 :     OK (LAGraph_NameOfType  (name, GrB_UINT8, msg)) ;
+      55           1 :     OK (strcmp (name, "uint8_t")) ;
+      56             : 
+      57           1 :     OK (LAGraph_NameOfType  (name, GrB_UINT16, msg)) ;
+      58           1 :     OK (strcmp (name, "uint16_t")) ;
+      59             : 
+      60           1 :     OK (LAGraph_NameOfType  (name, GrB_UINT32, msg)) ;
+      61           1 :     OK (strcmp (name, "uint32_t")) ;
+      62             : 
+      63           1 :     OK (LAGraph_NameOfType  (name, GrB_UINT64, msg)) ;
+      64           1 :     OK (strcmp (name, "uint64_t")) ;
+      65             : 
+      66           1 :     OK (LAGraph_NameOfType  (name, GrB_FP32, msg)) ;
+      67           1 :     OK (strcmp (name, "float")) ;
+      68             : 
+      69           1 :     OK (LAGraph_NameOfType  (name, GrB_FP64, msg)) ;
+      70           1 :     OK (strcmp (name, "double")) ;
+      71             : 
+      72             :     char typename [LAGRAPH_MAX_NAME_LEN] ;
+      73           1 :     OK (GrB_Scalar_new (&s, GrB_INT32)) ;
+      74           1 :     OK (LAGraph_Scalar_TypeName (name, s, msg)) ;
+      75           1 :     OK (strcmp (name, "int32_t")) ;
+      76           1 :     TEST_CHECK (LAGraph_Scalar_TypeName (NULL, s, msg) == GrB_NULL_POINTER) ;
+      77           1 :     TEST_CHECK (LAGraph_Scalar_TypeName (name, NULL, msg) == GrB_NULL_POINTER) ;
+      78             : 
+      79           1 :     name [0] = '\0' ;
+      80           1 :     OK (GrB_Type_new (&type, sizeof (myint))) ;
+      81           1 :     int result = LAGraph_NameOfType (name, type, msg) ;
+      82           1 :     TEST_CHECK (result == GrB_NOT_IMPLEMENTED) ;
+      83           1 :     printf ("\nmsg: %s\n", msg) ;
+      84             : 
+      85           1 :     TEST_CHECK (LAGraph_NameOfType (NULL, NULL, msg) == GrB_NULL_POINTER) ;
+      86           1 :     printf ("\nmsg: %s\n", msg) ;
+      87             : 
+      88           1 :     TEST_CHECK (LAGraph_NameOfType (name, NULL, msg) == GrB_NULL_POINTER) ;
+      89           1 :     printf ("msg: %s\n", msg) ;
+      90             : 
+      91           1 :     TEST_CHECK (LAGraph_NameOfType (NULL, GrB_BOOL, msg) == GrB_NULL_POINTER) ;
+      92           1 :     printf ("msg: %s\n", msg) ;
+      93             : 
+      94           1 :     GrB_free (&s) ;
+      95           1 :     GrB_free (&type) ;
+      96           1 :     OK (LAGraph_Finalize (msg)) ;
+      97           1 : }
+      98             : 
+      99             : //------------------------------------------------------------------------------
+     100             : // test_TypeSize :  test LAGraph_SizeOfType
+     101             : //------------------------------------------------------------------------------
+     102             : 
+     103           1 : void test_TypeSize (void)
+     104             : {
+     105           1 :     OK (LAGraph_Init (msg)) ;
+     106             :     size_t size ;
+     107             : 
+     108           1 :     size = 0 ;
+     109           1 :     OK (LAGraph_SizeOfType  (&size, GrB_BOOL, msg)) ;
+     110           1 :     TEST_CHECK (size == sizeof (bool)) ;
+     111             : 
+     112           1 :     size = 0 ;
+     113           1 :     OK (LAGraph_SizeOfType  (&size, GrB_INT8, msg)) ;
+     114           1 :     TEST_CHECK (size == sizeof (int8_t)) ;
+     115             : 
+     116           1 :     size = 0 ;
+     117           1 :     OK (LAGraph_SizeOfType  (&size, GrB_INT16, msg)) ;
+     118           1 :     TEST_CHECK (size == sizeof (int16_t)) ;
+     119             : 
+     120           1 :     size = 0 ;
+     121           1 :     OK (LAGraph_SizeOfType  (&size, GrB_INT32, msg)) ;
+     122           1 :     TEST_CHECK (size == sizeof (int32_t)) ;
+     123             : 
+     124           1 :     size = 0 ;
+     125           1 :     OK (LAGraph_SizeOfType  (&size, GrB_INT64, msg)) ;
+     126           1 :     TEST_CHECK (size == sizeof (int64_t)) ;
+     127             : 
+     128           1 :     size = 0 ;
+     129           1 :     OK (LAGraph_SizeOfType  (&size, GrB_UINT8, msg)) ;
+     130           1 :     TEST_CHECK (size == sizeof (uint8_t)) ;
+     131             : 
+     132           1 :     size = 0 ;
+     133           1 :     OK (LAGraph_SizeOfType  (&size, GrB_UINT16, msg)) ;
+     134           1 :     TEST_CHECK (size == sizeof (uint16_t)) ;
+     135             : 
+     136           1 :     size = 0 ;
+     137           1 :     OK (LAGraph_SizeOfType  (&size, GrB_UINT32, msg)) ;
+     138           1 :     TEST_CHECK (size == sizeof (uint32_t)) ;
+     139             : 
+     140           1 :     size = 0 ;
+     141           1 :     OK (LAGraph_SizeOfType  (&size, GrB_UINT64, msg)) ;
+     142           1 :     TEST_CHECK (size == sizeof (uint64_t)) ;
+     143             : 
+     144           1 :     size = 0 ;
+     145           1 :     OK (LAGraph_SizeOfType  (&size, GrB_FP32, msg)) ;
+     146           1 :     TEST_CHECK (size == sizeof (float)) ;
+     147             : 
+     148           1 :     size = 0 ;
+     149           1 :     OK (LAGraph_SizeOfType  (&size, GrB_FP64, msg)) ;
+     150           1 :     TEST_CHECK (size == sizeof (double)) ;
+     151             : 
+     152           1 :     size = 0 ;
+     153           1 :     OK (GrB_Type_new (&type, sizeof (myint))) ;
+     154           1 :     int result = LAGraph_SizeOfType (&size, type, msg) ;
+     155             :     #if LAGRAPH_SUITESPARSE
+     156           1 :     printf ("\nSuiteSparse knows the type size: [%g]\n", (double) size) ;
+     157           1 :     TEST_CHECK (result == GrB_SUCCESS) ;
+     158           1 :     TEST_CHECK (size == sizeof (myint)) ;
+     159             :     #else
+     160             :     TEST_CHECK (result == GrB_NOT_IMPLEMENTED) ;
+     161             :     printf ("\nmsg: %s\n", msg) ;
+     162             :     #endif
+     163             : 
+     164           1 :     TEST_CHECK (LAGraph_SizeOfType (NULL, NULL, msg) == GrB_NULL_POINTER) ;
+     165           1 :     printf ("\nmsg: %s\n", msg) ;
+     166             : 
+     167           1 :     TEST_CHECK (LAGraph_SizeOfType (&size, NULL, msg) == GrB_NULL_POINTER) ;
+     168           1 :     printf ("msg: %s\n", msg) ;
+     169             : 
+     170           1 :     TEST_CHECK (LAGraph_SizeOfType (NULL, GrB_BOOL, msg) == GrB_NULL_POINTER) ;
+     171           1 :     printf ("msg: %s\n", msg) ;
+     172             : 
+     173           1 :     GrB_free (&type) ;
+     174           1 :     OK (LAGraph_Finalize (msg)) ;
+     175           1 : }
+     176             : 
+     177             : //-----------------------------------------------------------------------------
+     178             : // TEST_LIST: the list of tasks for this entire test
+     179             : //-----------------------------------------------------------------------------
+     180             : 
+     181             : TEST_LIST =
+     182             : {
+     183             :     { "TypeName", test_TypeName  },
+     184             :     { "TypeSize", test_TypeSize  },
+     185             :     // no brutal test needed
+     186             :     { NULL, NULL }
+     187             : } ;
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_Vector_Print.c.func-sort-c.html b/src/test/test_Vector_Print.c.func-sort-c.html new file mode 100644 index 0000000000..505e58bc9b --- /dev/null +++ b/src/test/test_Vector_Print.c.func-sort-c.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_Vector_Print.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_Vector_Print.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:142142100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_print1
test_print_brutal1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_Vector_Print.c.func.html b/src/test/test_Vector_Print.c.func.html new file mode 100644 index 0000000000..69b660b3bf --- /dev/null +++ b/src/test/test_Vector_Print.c.func.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_Vector_Print.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_Vector_Print.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:142142100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_print1
test_print_brutal1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_Vector_Print.c.gcov.html b/src/test/test_Vector_Print.c.gcov.html new file mode 100644 index 0000000000..d81302cea6 --- /dev/null +++ b/src/test/test_Vector_Print.c.gcov.html @@ -0,0 +1,294 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_Vector_Print.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_Vector_Print.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:142142100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //-----------------------------------------------------------------------------
+       2             : // LAGraph/src/test/test_Vector_Print.c: test LAGraph_Vector_Print
+       3             : //-----------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //-----------------------------------------------------------------------------
+      17             : 
+      18             : #include "LAGraph_test.h"
+      19             : 
+      20             : char msg [LAGRAPH_MSG_LEN] ;
+      21             : GrB_Vector v = NULL ;
+      22             : GrB_Index n = 40 ;
+      23             : 
+      24             : //-----------------------------------------------------------------------------
+      25             : // test_print
+      26             : //-----------------------------------------------------------------------------
+      27             : 
+      28           1 : void test_print (void)
+      29             : {
+      30           1 :     OK (LAGraph_Init (msg)) ;
+      31           1 :     printf ("\n") ;
+      32           1 :     LAGraph_PrintLevel pr = LAGraph_SHORT ;
+      33             : 
+      34           1 :     OK (GrB_Vector_new (&v, GrB_BOOL, n)) ;
+      35           1 :     OK (GrB_assign (v, NULL, NULL, 0, GrB_ALL, n, NULL)) ;
+      36           1 :     OK (GrB_Vector_setElement (v, 1, 0)) ;
+      37           1 :     OK (LAGraph_Vector_Print (v, pr, stdout, msg)) ;
+      38           1 :     OK (GrB_Vector_free (&v)) ;
+      39             : 
+      40           1 :     OK (GrB_Vector_new (&v, GrB_INT8, n)) ;
+      41           1 :     OK (GrB_assign (v, NULL, NULL, 0, GrB_ALL, n, NULL)) ;
+      42           1 :     OK (GrB_Vector_setElement (v, -8, 0)) ;
+      43           1 :     OK (LAGraph_Vector_Print (v, pr, stdout, msg)) ;
+      44           1 :     OK (GrB_Vector_free (&v)) ;
+      45             : 
+      46           1 :     OK (GrB_Vector_new (&v, GrB_INT16, n)) ;
+      47           1 :     OK (GrB_assign (v, NULL, NULL, 0, GrB_ALL, n, NULL)) ;
+      48           1 :     OK (GrB_Vector_setElement (v, -16, 0)) ;
+      49           1 :     OK (LAGraph_Vector_Print (v, pr, stdout, msg)) ;
+      50           1 :     OK (GrB_Vector_free (&v)) ;
+      51             : 
+      52           1 :     OK (GrB_Vector_new (&v, GrB_INT32, n)) ;
+      53           1 :     OK (GrB_assign (v, NULL, NULL, 0, GrB_ALL, n, NULL)) ;
+      54           1 :     OK (GrB_Vector_setElement (v, -32, 0)) ;
+      55           1 :     OK (LAGraph_Vector_Print (v, pr, stdout, msg)) ;
+      56           1 :     OK (GrB_Vector_free (&v)) ;
+      57             : 
+      58           1 :     OK (GrB_Vector_new (&v, GrB_INT64, n)) ;
+      59           1 :     OK (GrB_assign (v, NULL, NULL, 0, GrB_ALL, n, NULL)) ;
+      60           1 :     OK (GrB_Vector_setElement (v, -64, 0)) ;
+      61           1 :     OK (LAGraph_Vector_Print (v, pr, stdout, msg)) ;
+      62           1 :     OK (GrB_Vector_free (&v)) ;
+      63             : 
+      64           1 :     OK (GrB_Vector_new (&v, GrB_UINT8, n)) ;
+      65           1 :     OK (GrB_assign (v, NULL, NULL, 0, GrB_ALL, n, NULL)) ;
+      66           1 :     OK (GrB_Vector_setElement (v, 8, 0)) ;
+      67           1 :     OK (LAGraph_Vector_Print (v, pr, stdout, msg)) ;
+      68           1 :     OK (GrB_Vector_free (&v)) ;
+      69             : 
+      70           1 :     OK (GrB_Vector_new (&v, GrB_UINT16, n)) ;
+      71           1 :     OK (GrB_assign (v, NULL, NULL, 0, GrB_ALL, n, NULL)) ;
+      72           1 :     OK (GrB_Vector_setElement (v, 16, 0)) ;
+      73           1 :     OK (LAGraph_Vector_Print (v, pr, stdout, msg)) ;
+      74           1 :     OK (GrB_Vector_free (&v)) ;
+      75             : 
+      76           1 :     OK (GrB_Vector_new (&v, GrB_UINT32, n)) ;
+      77           1 :     OK (GrB_assign (v, NULL, NULL, 0, GrB_ALL, n, NULL)) ;
+      78           1 :     OK (GrB_Vector_setElement (v, 32, 0)) ;
+      79           1 :     OK (LAGraph_Vector_Print (v, pr, stdout, msg)) ;
+      80           1 :     OK (GrB_Vector_free (&v)) ;
+      81             : 
+      82           1 :     OK (GrB_Vector_new (&v, GrB_UINT64, n)) ;
+      83           1 :     OK (GrB_assign (v, NULL, NULL, 0, GrB_ALL, n, NULL)) ;
+      84           1 :     OK (GrB_Vector_setElement (v, 64, 0)) ;
+      85           1 :     OK (LAGraph_Vector_Print (v, pr, stdout, msg)) ;
+      86           1 :     OK (GrB_Vector_free (&v)) ;
+      87             : 
+      88           1 :     OK (GrB_Vector_new (&v, GrB_FP32, n)) ;
+      89           1 :     OK (GrB_assign (v, NULL, NULL, 0, GrB_ALL, n, NULL)) ;
+      90           1 :     OK (GrB_Vector_setElement (v, 3.14159, 0)) ;
+      91           1 :     OK (LAGraph_Vector_Print (v, pr, stdout, msg)) ;
+      92           1 :     OK (GrB_Vector_free (&v)) ;
+      93             : 
+      94           1 :     OK (GrB_Vector_new (&v, GrB_FP64, n)) ;
+      95           1 :     OK (GrB_assign (v, NULL, NULL, 0, GrB_ALL, n, NULL)) ;
+      96           1 :     OK (GrB_Vector_setElement (v, 99.999, 0)) ;
+      97           1 :     OK (LAGraph_Vector_Print (v, pr, stdout, msg)) ;
+      98             : 
+      99             :     // attempt to print to a NULL file, which should fail
+     100           1 :     int result = LAGraph_Vector_Print (v, pr, NULL, msg) ;
+     101           1 :     TEST_CHECK (result == GrB_NULL_POINTER) ;
+     102           1 :     OK (GrB_Vector_free (&v)) ;
+     103             : 
+     104             :     // attempt to print a vector with a user-defined type, which should fail
+     105           1 :     GrB_Type type = NULL ;
+     106           1 :     OK (GrB_Type_new (&type, sizeof (int))) ;
+     107           1 :     OK (GrB_Vector_new (&v, type, n)) ;
+     108           1 :     result = LAGraph_Vector_Print (v, pr, stdout, msg) ;
+     109           1 :     TEST_CHECK (result == GrB_NOT_IMPLEMENTED) ;
+     110           1 :     OK (GrB_Vector_free (&v)) ;
+     111             : 
+     112           1 :     OK (GrB_Type_free (&type)) ;
+     113           1 :     OK (LAGraph_Finalize (msg)) ;
+     114           1 : }
+     115             : 
+     116             : //-----------------------------------------------------------------------------
+     117             : // test_print_brutal
+     118             : //-----------------------------------------------------------------------------
+     119             : 
+     120             : #if LAGRAPH_SUITESPARSE
+     121           1 : void test_print_brutal (void)
+     122             : {
+     123           1 :     OK (LG_brutal_setup (msg)) ;
+     124           1 :     printf ("\n") ;
+     125           1 :     LAGraph_PrintLevel pr = LAGraph_SHORT ;
+     126             : 
+     127           1 :     OK (GrB_Vector_new (&v, GrB_BOOL, n)) ;
+     128           1 :     OK (GrB_assign (v, NULL, NULL, 0, GrB_ALL, n, NULL)) ;
+     129           1 :     OK (GrB_Vector_setElement (v, 1, 0)) ;
+     130           1 :     OK (GrB_wait (v, GrB_MATERIALIZE)) ;
+     131           3 :     LG_BRUTAL_BURBLE (LAGraph_Vector_Print (v, pr, stdout, msg)) ;
+     132           1 :     OK (GrB_Vector_free (&v)) ;
+     133             : 
+     134           1 :     OK (GrB_Vector_new (&v, GrB_INT8, n)) ;
+     135           1 :     OK (GrB_assign (v, NULL, NULL, 0, GrB_ALL, n, NULL)) ;
+     136           1 :     OK (GrB_Vector_setElement (v, -8, 0)) ;
+     137           1 :     OK (GrB_wait (v, GrB_MATERIALIZE)) ;
+     138           3 :     LG_BRUTAL_BURBLE (LAGraph_Vector_Print (v, pr, stdout, msg)) ;
+     139           1 :     OK (GrB_Vector_free (&v)) ;
+     140             : 
+     141           1 :     OK (GrB_Vector_new (&v, GrB_INT16, n)) ;
+     142           1 :     OK (GrB_assign (v, NULL, NULL, 0, GrB_ALL, n, NULL)) ;
+     143           1 :     OK (GrB_Vector_setElement (v, -16, 0)) ;
+     144           1 :     OK (GrB_wait (v, GrB_MATERIALIZE)) ;
+     145           3 :     LG_BRUTAL_BURBLE (LAGraph_Vector_Print (v, pr, stdout, msg)) ;
+     146           1 :     OK (GrB_Vector_free (&v)) ;
+     147             : 
+     148           1 :     OK (GrB_Vector_new (&v, GrB_INT32, n)) ;
+     149           1 :     OK (GrB_assign (v, NULL, NULL, 0, GrB_ALL, n, NULL)) ;
+     150           1 :     OK (GrB_Vector_setElement (v, -32, 0)) ;
+     151           1 :     OK (GrB_wait (v, GrB_MATERIALIZE)) ;
+     152           3 :     LG_BRUTAL_BURBLE (LAGraph_Vector_Print (v, pr, stdout, msg)) ;
+     153           1 :     OK (GrB_Vector_free (&v)) ;
+     154             : 
+     155           1 :     OK (GrB_Vector_new (&v, GrB_INT64, n)) ;
+     156           1 :     OK (GrB_assign (v, NULL, NULL, 0, GrB_ALL, n, NULL)) ;
+     157           1 :     OK (GrB_Vector_setElement (v, -64, 0)) ;
+     158           1 :     OK (GrB_wait (v, GrB_MATERIALIZE)) ;
+     159           3 :     LG_BRUTAL_BURBLE (LAGraph_Vector_Print (v, pr, stdout, msg)) ;
+     160           1 :     OK (GrB_Vector_free (&v)) ;
+     161             : 
+     162           1 :     OK (GrB_Vector_new (&v, GrB_UINT8, n)) ;
+     163           1 :     OK (GrB_assign (v, NULL, NULL, 0, GrB_ALL, n, NULL)) ;
+     164           1 :     OK (GrB_Vector_setElement (v, 8, 0)) ;
+     165           1 :     OK (GrB_wait (v, GrB_MATERIALIZE)) ;
+     166           3 :     LG_BRUTAL_BURBLE (LAGraph_Vector_Print (v, pr, stdout, msg)) ;
+     167           1 :     OK (GrB_Vector_free (&v)) ;
+     168             : 
+     169           1 :     OK (GrB_Vector_new (&v, GrB_UINT16, n)) ;
+     170           1 :     OK (GrB_assign (v, NULL, NULL, 0, GrB_ALL, n, NULL)) ;
+     171           1 :     OK (GrB_Vector_setElement (v, 16, 0)) ;
+     172           1 :     OK (GrB_wait (v, GrB_MATERIALIZE)) ;
+     173           3 :     LG_BRUTAL_BURBLE (LAGraph_Vector_Print (v, pr, stdout, msg)) ;
+     174           1 :     OK (GrB_Vector_free (&v)) ;
+     175             : 
+     176           1 :     OK (GrB_Vector_new (&v, GrB_UINT32, n)) ;
+     177           1 :     OK (GrB_assign (v, NULL, NULL, 0, GrB_ALL, n, NULL)) ;
+     178           1 :     OK (GrB_Vector_setElement (v, 32, 0)) ;
+     179           1 :     OK (GrB_wait (v, GrB_MATERIALIZE)) ;
+     180           3 :     LG_BRUTAL_BURBLE (LAGraph_Vector_Print (v, pr, stdout, msg)) ;
+     181           1 :     OK (GrB_Vector_free (&v)) ;
+     182             : 
+     183           1 :     OK (GrB_Vector_new (&v, GrB_UINT64, n)) ;
+     184           1 :     OK (GrB_assign (v, NULL, NULL, 0, GrB_ALL, n, NULL)) ;
+     185           1 :     OK (GrB_Vector_setElement (v, 64, 0)) ;
+     186           1 :     OK (GrB_wait (v, GrB_MATERIALIZE)) ;
+     187           3 :     LG_BRUTAL_BURBLE (LAGraph_Vector_Print (v, pr, stdout, msg)) ;
+     188           1 :     OK (GrB_Vector_free (&v)) ;
+     189             : 
+     190           1 :     OK (GrB_Vector_new (&v, GrB_FP32, n)) ;
+     191           1 :     OK (GrB_assign (v, NULL, NULL, 0, GrB_ALL, n, NULL)) ;
+     192           1 :     OK (GrB_Vector_setElement (v, 3.14159, 0)) ;
+     193           1 :     OK (GrB_wait (v, GrB_MATERIALIZE)) ;
+     194           3 :     LG_BRUTAL_BURBLE (LAGraph_Vector_Print (v, pr, stdout, msg)) ;
+     195           1 :     OK (GrB_Vector_free (&v)) ;
+     196             : 
+     197           1 :     OK (GrB_Vector_new (&v, GrB_FP64, n)) ;
+     198           1 :     OK (GrB_assign (v, NULL, NULL, 0, GrB_ALL, n, NULL)) ;
+     199           1 :     OK (GrB_Vector_setElement (v, 99.999, 0)) ;
+     200           1 :     OK (GrB_wait (v, GrB_MATERIALIZE)) ;
+     201           3 :     LG_BRUTAL_BURBLE (LAGraph_Vector_Print (v, pr, stdout, msg)) ;
+     202           1 :     OK (GrB_Vector_free (&v)) ;
+     203             : 
+     204           1 :     OK (LG_brutal_teardown (msg)) ;
+     205           1 : }
+     206             : #endif
+     207             : 
+     208             : //-----------------------------------------------------------------------------
+     209             : // TEST_LIST: the list of tasks for this entire test
+     210             : //-----------------------------------------------------------------------------
+     211             : 
+     212             : TEST_LIST = {
+     213             :     {"test_print", test_print},
+     214             :     #if LAGRAPH_SUITESPARSE
+     215             :     {"test_print_brutal", test_print_brutal},
+     216             :     #endif
+     217             :     {NULL, NULL}
+     218             : };
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_Vector_Structure.c.func-sort-c.html b/src/test/test_Vector_Structure.c.func-sort-c.html new file mode 100644 index 0000000000..1cac2fa8e5 --- /dev/null +++ b/src/test/test_Vector_Structure.c.func-sort-c.html @@ -0,0 +1,92 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_Vector_Structure.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_Vector_Structure.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:8585100.0 %
Date:2024-08-29 20:08:04Functions:55100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_Vector_Structure1
test_Vector_Structure_brutal1
test_Vector_Structure_failures1
setup2
teardown2
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_Vector_Structure.c.func.html b/src/test/test_Vector_Structure.c.func.html new file mode 100644 index 0000000000..27c7e9144d --- /dev/null +++ b/src/test/test_Vector_Structure.c.func.html @@ -0,0 +1,92 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_Vector_Structure.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_Vector_Structure.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:8585100.0 %
Date:2024-08-29 20:08:04Functions:55100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
setup2
teardown2
test_Vector_Structure1
test_Vector_Structure_brutal1
test_Vector_Structure_failures1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_Vector_Structure.c.gcov.html b/src/test/test_Vector_Structure.c.gcov.html new file mode 100644 index 0000000000..7a9ef9dbb2 --- /dev/null +++ b/src/test/test_Vector_Structure.c.gcov.html @@ -0,0 +1,263 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_Vector_Structure.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_Vector_Structure.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:8585100.0 %
Date:2024-08-29 20:08:04Functions:55100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph/src/test/test_Vector_Structure.c:  test LAGraph_Vector_Structure
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include "LAGraph_test.h"
+      19             : #include "LG_internal.h"
+      20             : 
+      21             : //------------------------------------------------------------------------------
+      22             : // global variables
+      23             : //------------------------------------------------------------------------------
+      24             : 
+      25             : char msg [LAGRAPH_MSG_LEN] ;
+      26             : GrB_Vector w = NULL, u = NULL ;
+      27             : #define LEN 512
+      28             : char wtype_name [LAGRAPH_MAX_NAME_LEN] ;
+      29             : 
+      30             : //------------------------------------------------------------------------------
+      31             : // setup: start a test
+      32             : //------------------------------------------------------------------------------
+      33             : 
+      34           2 : void setup (void)
+      35             : {
+      36           2 :     OK (LAGraph_Init (msg)) ;
+      37           2 : }
+      38             : 
+      39             : //------------------------------------------------------------------------------
+      40             : // teardown: finalize a test
+      41             : //------------------------------------------------------------------------------
+      42             : 
+      43           2 : void teardown (void)
+      44             : {
+      45           2 :     OK (LAGraph_Finalize (msg)) ;
+      46           2 : }
+      47             : 
+      48             : //------------------------------------------------------------------------------
+      49             : // test_Vector_Structure:  test LAGraph_Vector_Structure
+      50             : //------------------------------------------------------------------------------
+      51             : 
+      52           1 : void test_Vector_Structure (void)
+      53             : {
+      54           1 :     setup ( ) ;
+      55           1 :     printf ("\n") ;
+      56             : 
+      57             :     // create a test vector
+      58           1 :     GrB_Index n = 10 ;
+      59           1 :     OK (GrB_Vector_new (&u, GrB_FP64, n)) ;
+      60           1 :     OK (GrB_Vector_setElement_FP64 (u, 3.5, 0)) ;
+      61           1 :     OK (GrB_Vector_setElement_FP64 (u, 4.7, 3)) ;
+      62           1 :     OK (GrB_Vector_setElement_FP64 (u, 9.8, 7)) ;
+      63           1 :     OK (LAGraph_Vector_Print (u, LAGraph_COMPLETE_VERBOSE, stdout, msg)) ;
+      64             : 
+      65             :     // get its structure
+      66           1 :     int result = LAGraph_Vector_Structure (&w, u, msg) ;
+      67           1 :     TEST_CHECK (result == GrB_SUCCESS) ;
+      68           1 :     OK (LAGraph_Vector_Print (w, LAGraph_COMPLETE_VERBOSE, stdout, msg)) ;
+      69             : 
+      70             :     // check it
+      71             :     GrB_Index nvals ;
+      72           1 :     OK (GrB_Vector_size (&n, u)) ;
+      73           1 :     TEST_CHECK (n == 10) ;
+      74           1 :     OK (GrB_Vector_nvals (&nvals, u)) ;
+      75           1 :     TEST_CHECK (nvals == 3) ;
+      76           1 :     OK (LAGraph_Vector_TypeName (wtype_name, w, msg)) ;
+      77           1 :     TEST_CHECK (MATCHNAME (wtype_name, "bool")) ;
+      78             : 
+      79           1 :     bool x = false ;
+      80           1 :     result = GrB_Vector_extractElement_BOOL (&x, w, 0) ;
+      81           1 :     TEST_CHECK (result == GrB_SUCCESS) ;
+      82           1 :     TEST_CHECK (x) ;
+      83             : 
+      84           1 :     x = false ;
+      85           1 :     result = GrB_Vector_extractElement_BOOL (&x, w, 3) ;
+      86           1 :     TEST_CHECK (result == GrB_SUCCESS) ;
+      87           1 :     TEST_CHECK (x) ;
+      88             : 
+      89           1 :     x = false ;
+      90           1 :     result = GrB_Vector_extractElement_BOOL (&x, w, 7) ;
+      91           1 :     TEST_CHECK (result == GrB_SUCCESS) ;
+      92           1 :     TEST_CHECK (x) ;
+      93             : 
+      94           1 :     OK (GrB_free (&w)) ;
+      95           1 :     OK (GrB_free (&u)) ;
+      96             : 
+      97           1 :     teardown ( ) ;
+      98           1 : }
+      99             : 
+     100             : //------------------------------------------------------------------------------
+     101             : // test_Vector_Structure_brutal
+     102             : //------------------------------------------------------------------------------
+     103             : 
+     104             : #if LAGRAPH_SUITESPARSE
+     105           1 : void test_Vector_Structure_brutal (void)
+     106             : {
+     107           1 :     OK (LG_brutal_setup (msg)) ;
+     108           1 :     printf ("\n") ;
+     109             : 
+     110             :     // create a test vector
+     111           1 :     GrB_Index n = 10 ;
+     112           1 :     OK (GrB_Vector_new (&u, GrB_FP64, n)) ;
+     113           1 :     OK (GrB_Vector_setElement_FP64 (u, 3.5, 0)) ;
+     114           1 :     OK (GrB_Vector_setElement_FP64 (u, 4.7, 3)) ;
+     115           1 :     OK (GrB_Vector_setElement_FP64 (u, 9.8, 7)) ;
+     116             : 
+     117             :     // get its structure
+     118           1 :     int result = LAGraph_Vector_Structure (&w, u, msg) ;
+     119           1 :     TEST_CHECK (result == GrB_SUCCESS) ;
+     120           1 :     OK (LAGraph_Vector_Print (w, LAGraph_COMPLETE_VERBOSE, stdout, msg)) ;
+     121             : 
+     122             :     // check it
+     123             :     GrB_Index nvals ;
+     124           1 :     OK (GrB_Vector_size (&n, u)) ;
+     125           1 :     TEST_CHECK (n == 10) ;
+     126           1 :     OK (GrB_Vector_nvals (&nvals, u)) ;
+     127           1 :     TEST_CHECK (nvals == 3) ;
+     128           1 :     OK (LAGraph_Vector_TypeName (wtype_name, w, msg)) ;
+     129           1 :     TEST_CHECK (MATCHNAME (wtype_name, "bool")) ;
+     130             : 
+     131           1 :     bool x = false ;
+     132           1 :     result = GrB_Vector_extractElement_BOOL (&x, w, 0) ;
+     133           1 :     TEST_CHECK (result == GrB_SUCCESS) ;
+     134           1 :     TEST_CHECK (x) ;
+     135             : 
+     136           1 :     x = false ;
+     137           1 :     result = GrB_Vector_extractElement_BOOL (&x, w, 3) ;
+     138           1 :     TEST_CHECK (result == GrB_SUCCESS) ;
+     139           1 :     TEST_CHECK (x) ;
+     140             : 
+     141           1 :     x = false ;
+     142           1 :     result = GrB_Vector_extractElement_BOOL (&x, w, 7) ;
+     143           1 :     TEST_CHECK (result == GrB_SUCCESS) ;
+     144           1 :     TEST_CHECK (x) ;
+     145             : 
+     146             : 
+     147           1 :     OK (GrB_free (&w)) ;
+     148           1 :     OK (GrB_free (&u)) ;
+     149             : 
+     150             : 
+     151           1 :     OK (LG_brutal_teardown (msg)) ;
+     152           1 : }
+     153             : #endif
+     154             : 
+     155             : //------------------------------------------------------------------------------
+     156             : // test_Vector_Structure_failures: test LAGraph_Vector_Structure error handling
+     157             : //------------------------------------------------------------------------------
+     158             : 
+     159           1 : void test_Vector_Structure_failures (void)
+     160             : {
+     161           1 :     setup ( ) ;
+     162             : 
+     163           1 :     w = NULL ;
+     164           1 :     int result = LAGraph_Vector_Structure (NULL, NULL, msg) ;
+     165           1 :     TEST_CHECK (result == GrB_NULL_POINTER) ;
+     166           1 :     printf ("\nmsg: [%s]\n", msg) ;
+     167           1 :     result = LAGraph_Vector_Structure (&w, NULL, msg) ;
+     168           1 :     TEST_CHECK (result == GrB_NULL_POINTER) ;
+     169           1 :     printf ("msg: [%s]\n", msg) ;
+     170           1 :     TEST_CHECK (w == NULL) ;
+     171             : 
+     172           1 :     teardown ( ) ;
+     173           1 : }
+     174             : 
+     175             : //-----------------------------------------------------------------------------
+     176             : // TEST_LIST: the list of tasks for this entire test
+     177             : //-----------------------------------------------------------------------------
+     178             : 
+     179             : TEST_LIST =
+     180             : {
+     181             :     { "Vector_Structure", test_Vector_Structure },
+     182             :     { "Vector_Structure_failures", test_Vector_Structure_failures },
+     183             :     #if LAGRAPH_SUITESPARSE
+     184             :     { "Vector_Structure_brutal", test_Vector_Structure_brutal },
+     185             :     #endif
+     186             :     { NULL, NULL }
+     187             : } ;
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_WallClockTime.c.func-sort-c.html b/src/test/test_WallClockTime.c.func-sort-c.html new file mode 100644 index 0000000000..4d9d3ae1b9 --- /dev/null +++ b/src/test/test_WallClockTime.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_WallClockTime.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_WallClockTime.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1212100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_WallClockTime1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_WallClockTime.c.func.html b/src/test/test_WallClockTime.c.func.html new file mode 100644 index 0000000000..cd147adccb --- /dev/null +++ b/src/test/test_WallClockTime.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_WallClockTime.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_WallClockTime.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1212100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_WallClockTime1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_WallClockTime.c.gcov.html b/src/test/test_WallClockTime.c.gcov.html new file mode 100644 index 0000000000..10a8c4d815 --- /dev/null +++ b/src/test/test_WallClockTime.c.gcov.html @@ -0,0 +1,144 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_WallClockTime.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_WallClockTime.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1212100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph/src/test/test_WallClockTime.c:  test LAGraph_WallClockTime
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include "LAGraph_test.h"
+      19             : 
+      20             : //------------------------------------------------------------------------------
+      21             : // global variables
+      22             : //------------------------------------------------------------------------------
+      23             : 
+      24             : double t ;
+      25             : char msg [LAGRAPH_MSG_LEN] ;
+      26             : 
+      27             : //------------------------------------------------------------------------------
+      28             : // test_WallClockTime:  test LAGraph_WallClockTime
+      29             : //------------------------------------------------------------------------------
+      30             : 
+      31           1 : void test_WallClockTime (void)
+      32             : {
+      33             : 
+      34           1 :     OK (LAGraph_Init (msg)) ;
+      35             : 
+      36             :     // start the timer
+      37           1 :     double t = LAGraph_WallClockTime ( ) ;
+      38             : 
+      39             :     // do some useless work
+      40           1 :     double x = msg [0] ;
+      41       10001 :     for (int64_t k = 0 ; k < 10000 ; k++)
+      42             :     {
+      43   100010000 :         for (int64_t i = 0 ; i < 10000 ; i++)
+      44             :         {
+      45   100000000 :             x = x + 1 ;
+      46   100000000 :             if (x > 100) x = x/2 ;
+      47             :         }
+      48             :     }
+      49             : 
+      50             :     // stop the timer
+      51           1 :     t = LAGraph_WallClockTime ( ) - t ;
+      52             : 
+      53             :     // print the result so the compiler doesn't remove the loops above
+      54           1 :     printf ("\nresult: %g, time: %g sec\n", x, t) ;
+      55             : 
+      56           1 :     OK (LAGraph_Finalize (msg)) ;
+      57           1 : }
+      58             : 
+      59             : //-----------------------------------------------------------------------------
+      60             : // TEST_LIST: the list of tasks for this entire test
+      61             : //-----------------------------------------------------------------------------
+      62             : 
+      63             : TEST_LIST =
+      64             : {
+      65             :     { "WallClockTime", test_WallClockTime },
+      66             :     // no brutal test needed
+      67             :     { NULL, NULL }
+      68             : } ;
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_Xinit.c.func-sort-c.html b/src/test/test_Xinit.c.func-sort-c.html new file mode 100644 index 0000000000..ab9d8dde52 --- /dev/null +++ b/src/test/test_Xinit.c.func-sort-c.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_Xinit.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_Xinit.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:7676100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_Xinit1
test_Xinit_brutal1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_Xinit.c.func.html b/src/test/test_Xinit.c.func.html new file mode 100644 index 0000000000..4d286e01cf --- /dev/null +++ b/src/test/test_Xinit.c.func.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_Xinit.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_Xinit.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:7676100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_Xinit1
test_Xinit_brutal1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_Xinit.c.gcov.html b/src/test/test_Xinit.c.gcov.html new file mode 100644 index 0000000000..9b27f47fba --- /dev/null +++ b/src/test/test_Xinit.c.gcov.html @@ -0,0 +1,262 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_Xinit.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_Xinit.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:7676100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph/src/test/test_Xinit.c:  test LAGr_Init and LAGraph_Global
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2023 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include "LAGraph_test.h"
+      19             : #include "LAGraphX.h"
+      20             : 
+      21             : // functions defined in LAGr_Init.c:
+      22             : LAGRAPH_PUBLIC void LG_set_LAGr_Init_has_been_called (bool setting) ;
+      23             : LAGRAPH_PUBLIC bool LG_get_LAGr_Init_has_been_called (void) ;
+      24             : 
+      25             : //------------------------------------------------------------------------------
+      26             : // global variables
+      27             : //------------------------------------------------------------------------------
+      28             : 
+      29             : char msg [LAGRAPH_MSG_LEN] ;
+      30             : 
+      31             : //------------------------------------------------------------------------------
+      32             : // test_Xinit:  test LAGr_Init
+      33             : //------------------------------------------------------------------------------
+      34             : 
+      35           1 : void test_Xinit (void)
+      36             : {
+      37             : 
+      38           1 :     printf ("\nTesting LAGr_Init: with expected errors\n") ;
+      39             : 
+      40           1 :     TEST_CHECK (LAGr_Init (GrB_NONBLOCKING, NULL, NULL, NULL, NULL, msg)
+      41             :         == GrB_NULL_POINTER) ;
+      42           1 :     printf ("msg: [%s]\n", msg) ;
+      43             : 
+      44           1 :     TEST_CHECK (LAGr_Init (GrB_NONBLOCKING, malloc, NULL, NULL, NULL, msg)
+      45             :         == GrB_NULL_POINTER) ;
+      46           1 :     printf ("msg: [%s]\n", msg) ;
+      47             : 
+      48           1 :     TEST_CHECK (LAGr_Init (GrB_NONBLOCKING, NULL, NULL, NULL, free, msg)
+      49             :         == GrB_NULL_POINTER) ;
+      50           1 :     printf ("msg: [%s]\n", msg) ;
+      51             : 
+      52           1 :     OK (LAGr_Init (GrB_NONBLOCKING, malloc, calloc, realloc, free, msg)) ;
+      53           1 :     printf ("msg: [%s]\n", msg) ;
+      54           1 :     TEST_CHECK (LG_get_LAGr_Init_has_been_called ( ) == true) ;
+      55             : 
+      56             :     // LAGr_Init cannot be called twice
+      57           1 :     int status = LAGr_Init (GrB_NONBLOCKING,
+      58             :         malloc, calloc, realloc, free, msg) ;
+      59           1 :     TEST_CHECK (status != GrB_SUCCESS) ;
+      60           1 :     printf ("msg: [%s]\n", msg) ;
+      61             : 
+      62           1 :     OK (LAGraph_Finalize (msg)) ;
+      63             : 
+      64             :     // the flag is still set after LAGraph_Finalize has been called,
+      65             :     // per LAGraph policy
+      66           1 :     TEST_CHECK (LG_get_LAGr_Init_has_been_called ( ) == true) ;
+      67             : 
+      68             :     // reset and try again
+      69           1 :     LG_set_LAGr_Init_has_been_called (false) ;
+      70           1 :     TEST_CHECK (LG_get_LAGr_Init_has_been_called ( ) == false) ;
+      71           1 :     OK (LAGr_Init (GrB_NONBLOCKING, malloc, calloc, realloc, free, msg)) ;
+      72           1 :     TEST_CHECK (LG_get_LAGr_Init_has_been_called ( ) == true) ;
+      73           1 :     OK (LAGraph_Finalize (msg)) ;
+      74           1 :     TEST_CHECK (LG_get_LAGr_Init_has_been_called ( ) == true) ;
+      75           1 : }
+      76             : 
+      77             : //------------------------------------------------------------------------------
+      78             : // test_Xinit_brutal:  test LAGr_Init with brutal memory debug
+      79             : //------------------------------------------------------------------------------
+      80             : 
+      81             : #if LAGRAPH_SUITESPARSE
+      82           1 : void test_Xinit_brutal (void)
+      83             : {
+      84             :     // no brutal memory failures, but test LG_brutal_malloc/calloc/realloc/free
+      85           1 :     LG_brutal = -1 ;
+      86           1 :     LG_nmalloc = 0 ;
+      87           1 :     OK (LAGr_Init (GrB_NONBLOCKING,
+      88             :         LG_brutal_malloc, LG_brutal_calloc, LG_brutal_realloc, LG_brutal_free,
+      89             :         msg)) ;
+      90             : 
+      91           1 :     int32_t *p = LG_brutal_malloc (42 * sizeof (int32_t)) ;
+      92           1 :     TEST_CHECK (p != NULL) ;
+      93           1 :     LG_brutal_free (p) ;
+      94           1 :     p = LG_brutal_calloc (42, sizeof (int32_t)) ;
+      95          43 :     for (int k = 0 ; k < 42 ; k++)
+      96             :     {
+      97          42 :         TEST_CHECK (p [k] == 0) ;
+      98             :     }
+      99           1 :     p = LG_brutal_realloc (p, 99 * sizeof (int32_t)) ;
+     100          43 :     for (int k = 0 ; k < 42 ; k++)
+     101             :     {
+     102          42 :         TEST_CHECK (p [k] == 0) ;
+     103             :     }
+     104           1 :     LG_brutal_free (p) ;
+     105           1 :     p = LG_brutal_realloc (NULL, 4 * sizeof (int32_t)) ;
+     106           5 :     for (int k = 0 ; k < 4 ; k++)
+     107             :     {
+     108           4 :         p [k] = k ;
+     109             :     }
+     110           1 :     LG_brutal_free (p) ;
+     111             : 
+     112           1 :     OK (LAGraph_Finalize (msg)) ;
+     113           1 :     TEST_CHECK (LG_nmalloc == 0) ;
+     114             : 
+     115             :     // brutal tests: keep giving the method more malloc's until it succeeds
+     116             : 
+     117          13 :     for (int nbrutal = 0 ; nbrutal < 1000 ; nbrutal++)
+     118             :     {
+     119          13 :         LG_brutal = nbrutal ;
+     120          13 :         GB_Global_GrB_init_called_set (false) ;
+     121          13 :         GrB_Info info = GxB_init (GrB_NONBLOCKING, LG_brutal_malloc,
+     122             :             LG_brutal_calloc, LG_brutal_realloc, LG_brutal_free) ;
+     123          13 :         void *p = NULL, *pnew = NULL ;
+     124          13 :         bool ok = false ;
+     125          13 :         if (info == GrB_SUCCESS)
+     126             :         {
+     127           3 :             p = LG_brutal_realloc (NULL, 42) ;
+     128           3 :             pnew = NULL ;
+     129           3 :             ok = (p != NULL) ;
+     130           3 :             if (ok)
+     131             :             {
+     132           2 :                 pnew = LG_brutal_realloc (p, 107) ;
+     133           2 :                 ok = (pnew != NULL) ;
+     134           2 :                 LG_brutal_free (ok ? pnew : p) ;
+     135             :             }
+     136             :         }
+     137          13 :         if (ok)
+     138             :         {
+     139           1 :             OK (GrB_finalize ( )) ;
+     140           1 :             printf ("\nGxB_init, finally: %d %g\n", nbrutal,
+     141             :                 (double) LG_nmalloc) ;
+     142           1 :             TEST_CHECK (LG_nmalloc == 0) ;
+     143           1 :             break ;
+     144             :         }
+     145             :     }
+     146             : 
+     147           1 :     TEST_CHECK (LG_get_LAGr_Init_has_been_called ( ) == true) ;
+     148             : 
+     149          52 :     for (int nbrutal = 0 ; nbrutal < 1000 ; nbrutal++)
+     150             :     {
+     151          52 :         LG_brutal = nbrutal ;
+     152             :         // reset both GraphBLAS and LAGraph
+     153          52 :         GB_Global_GrB_init_called_set (false) ;
+     154          52 :         LG_set_LAGr_Init_has_been_called (false) ;
+     155          52 :         TEST_CHECK (LG_get_LAGr_Init_has_been_called ( ) == false) ;
+     156             :         // try to initialize GraphBLAS and LAGraph
+     157          52 :         int result = LAGr_Init (GrB_NONBLOCKING,
+     158             :             LG_brutal_malloc, LG_brutal_calloc,
+     159             :             LG_brutal_realloc, LG_brutal_free, msg) ;
+     160          52 :         if (result == 0)
+     161             :         {
+     162             :             // success
+     163           1 :             OK (LAGraph_Finalize (msg)) ;
+     164           1 :             printf ("LAGr_Init: finally: %d %g\n", nbrutal,
+     165             :                 (double) LG_nmalloc) ;
+     166           1 :             TEST_CHECK (LG_nmalloc == 0) ;
+     167           1 :             break ;
+     168             :         }
+     169             :         // failure: free anything partially allocated
+     170          51 :         OK (LAGraph_Finalize (msg)) ;
+     171             :     }
+     172           1 : }
+     173             : #endif
+     174             : 
+     175             : //-----------------------------------------------------------------------------
+     176             : // TEST_LIST: the list of tasks for this entire test
+     177             : //-----------------------------------------------------------------------------
+     178             : 
+     179             : TEST_LIST =
+     180             : {
+     181             :     { "Xinit", test_Xinit },
+     182             :     #if LAGRAPH_SUITESPARSE
+     183             :     { "Xinit_brutal", test_Xinit_brutal },
+     184             :     #endif
+     185             :     { NULL, NULL }
+     186             : } ;
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_acutest.c.func-sort-c.html b/src/test/test_acutest.c.func-sort-c.html new file mode 100644 index 0000000000..fb095c39a9 --- /dev/null +++ b/src/test/test_acutest.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_acutest.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_acutest.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:44100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_dummy1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_acutest.c.func.html b/src/test/test_acutest.c.func.html new file mode 100644 index 0000000000..89092c656f --- /dev/null +++ b/src/test/test_acutest.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_acutest.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_acutest.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:44100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_dummy1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_acutest.c.gcov.html b/src/test/test_acutest.c.gcov.html new file mode 100644 index 0000000000..de77e7a335 --- /dev/null +++ b/src/test/test_acutest.c.gcov.html @@ -0,0 +1,124 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_acutest.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_acutest.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:44100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //-----------------------------------------------------------------------------
+       2             : // LAGraph/src/test/test_acutest.c: simple demo of how to use acutest
+       3             : //-----------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Scott McMillan, SEI Carnegie Mellon University
+      15             : 
+      16             : //-----------------------------------------------------------------------------
+      17             : 
+      18             : #include "LAGraph_test.h"
+      19             : 
+      20             : //****************************************************************************
+      21           1 : void test_dummy(void)
+      22             : {
+      23           1 :     TEST_CHECK(42 == 42);
+      24             :     // this test message will not appear in the log, because the test passes:
+      25           1 :     TEST_MSG ("Testing equality %d", 42) ;
+      26           1 : }
+      27             : 
+      28             : //****************************************************************************
+      29             : #if 0
+      30             : void test_dummy_fails(void)
+      31             : {
+      32             :     TEST_CHECK(42 == 0);
+      33             :     // this test message will appear in the log, because the test fails:
+      34             :     TEST_MSG ("this test is supposed to fail, because %d != %d\n", 42, 0) ;
+      35             : }
+      36             : #endif
+      37             : 
+      38             : //****************************************************************************
+      39             : //****************************************************************************
+      40             : 
+      41             : // uncomment the line below to create an intentional test failure.
+      42             : 
+      43             : TEST_LIST = {
+      44             :     {"dummy", test_dummy},
+      45             : //  {"dummy_fails", test_dummy_fails},
+      46             :     // no brutal test needed
+      47             :     {NULL, NULL}
+      48             : };
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_export.c.func-sort-c.html b/src/test/test_export.c.func-sort-c.html new file mode 100644 index 0000000000..442af48441 --- /dev/null +++ b/src/test/test_export.c.func-sort-c.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_export.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_export.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:8080100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_export1
test_export_brutal1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_export.c.func.html b/src/test/test_export.c.func.html new file mode 100644 index 0000000000..565d4d8840 --- /dev/null +++ b/src/test/test_export.c.func.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_export.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_export.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:8080100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_export1
test_export_brutal1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_export.c.gcov.html b/src/test/test_export.c.gcov.html new file mode 100644 index 0000000000..b98adf07f6 --- /dev/null +++ b/src/test/test_export.c.gcov.html @@ -0,0 +1,295 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_export.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_export.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:8080100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph/src/test/test_export.c: test LG_check_export
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include <LAGraph_test.h>
+      19             : 
+      20             : char msg[LAGRAPH_MSG_LEN];
+      21             : LAGraph_Graph G = NULL;
+      22             : GrB_Type atype = NULL ;
+      23             : char atype_name [LAGRAPH_MAX_NAME_LEN] ;
+      24             : 
+      25             : #define LEN 512
+      26             : char filename [LEN+1] ;
+      27             : 
+      28             : typedef struct
+      29             : {
+      30             :     LAGraph_Kind kind ;
+      31             :     const char *name ;
+      32             : }
+      33             : matrix_info ;
+      34             : 
+      35             : const matrix_info files [ ] =
+      36             : {
+      37             :     { LAGraph_ADJACENCY_UNDIRECTED, "A.mtx" },
+      38             :     { LAGraph_ADJACENCY_DIRECTED,   "cover.mtx" },
+      39             :     { LAGraph_ADJACENCY_UNDIRECTED, "jagmesh7.mtx" },
+      40             :     { LAGraph_ADJACENCY_DIRECTED,   "ldbc-cdlp-directed-example.mtx" },
+      41             :     { LAGraph_ADJACENCY_UNDIRECTED, "ldbc-cdlp-undirected-example.mtx" },
+      42             :     { LAGraph_ADJACENCY_DIRECTED,   "ldbc-directed-example.mtx" },
+      43             :     { LAGraph_ADJACENCY_UNDIRECTED, "ldbc-undirected-example.mtx" },
+      44             :     { LAGraph_ADJACENCY_UNDIRECTED, "ldbc-wcc-example.mtx" },
+      45             :     { LAGraph_ADJACENCY_UNDIRECTED, "LFAT5.mtx" },
+      46             :     { LAGraph_ADJACENCY_DIRECTED,   "msf1.mtx" },
+      47             :     { LAGraph_ADJACENCY_DIRECTED,   "msf2.mtx" },
+      48             :     { LAGraph_ADJACENCY_DIRECTED,   "msf3.mtx" },
+      49             :     { LAGraph_ADJACENCY_DIRECTED,   "sample2.mtx" },
+      50             :     { LAGraph_ADJACENCY_DIRECTED,   "sample.mtx" },
+      51             :     { LAGraph_ADJACENCY_DIRECTED,   "olm1000.mtx" },
+      52             :     { LAGraph_ADJACENCY_UNDIRECTED, "bcsstk13.mtx" },
+      53             :     { LAGraph_ADJACENCY_DIRECTED,   "cryg2500.mtx" },
+      54             :     { LAGraph_ADJACENCY_UNDIRECTED, "tree-example.mtx" },
+      55             :     { LAGraph_ADJACENCY_DIRECTED,   "west0067.mtx" },
+      56             :     { LAGraph_ADJACENCY_UNDIRECTED, "karate.mtx" },
+      57             :     { LAGraph_ADJACENCY_DIRECTED,   "matrix_bool.mtx" },
+      58             :     { LAGraph_ADJACENCY_DIRECTED,   "matrix_int8.mtx" },
+      59             :     { LAGraph_ADJACENCY_DIRECTED,   "matrix_int16.mtx" },
+      60             :     { LAGraph_ADJACENCY_DIRECTED,   "matrix_int32.mtx" },
+      61             :     { LAGraph_ADJACENCY_DIRECTED,   "matrix_int64.mtx" },
+      62             :     { LAGraph_ADJACENCY_DIRECTED,   "matrix_uint8.mtx" },
+      63             :     { LAGraph_ADJACENCY_DIRECTED,   "matrix_uint16.mtx" },
+      64             :     { LAGraph_ADJACENCY_DIRECTED,   "matrix_int32.mtx" },
+      65             :     { LAGraph_ADJACENCY_DIRECTED,   "matrix_uint64.mtx" },
+      66             :     { LAGraph_ADJACENCY_DIRECTED,   "skew_fp32.mtx" },
+      67             :     { LAGraph_ADJACENCY_UNDIRECTED, "pushpull.mtx" },
+      68             :     { LAGRAPH_UNKNOWN, "" },
+      69             : } ;
+      70             : 
+      71             : //------------------------------------------------------------------------------
+      72             : // test_export
+      73             : //------------------------------------------------------------------------------
+      74             : 
+      75           1 : void test_export (void)
+      76             : {
+      77           1 :     LAGraph_Init (msg);
+      78           1 :     GrB_Matrix A = NULL, C = NULL ;
+      79             : 
+      80           1 :     for (int k = 0 ; ; k++)
+      81          31 :     {
+      82             : 
+      83             :         // load the adjacency matrix as A
+      84          32 :         const char *aname = files [k].name ;
+      85          32 :         LAGraph_Kind kind = files [k].kind ;
+      86          32 :         if (strlen (aname) == 0) break;
+      87          31 :         TEST_CASE (aname) ;
+      88          31 :         printf ("\nMatrix: %s\n", aname) ;
+      89          31 :         snprintf (filename, LEN, LG_DATA_DIR "%s", aname) ;
+      90          31 :         FILE *f = fopen (filename, "r") ;
+      91          31 :         TEST_CHECK (f != NULL) ;
+      92          31 :         OK (LAGraph_MMRead (&A, f, msg)) ;
+      93          31 :         OK (fclose (f)) ;
+      94          31 :         TEST_MSG ("Loading of adjacency matrix failed") ;
+      95          31 :         OK (LAGraph_Matrix_TypeName (atype_name, A, msg)) ;
+      96          31 :         OK (LAGraph_TypeFromName (&atype, atype_name, msg)) ;
+      97             : 
+      98             :         // create the graph
+      99          31 :         OK (LAGraph_New (&G, &A, kind, msg)) ;
+     100          31 :         TEST_CHECK (A == NULL) ;    // A has been moved into G->A
+     101             : 
+     102             :         // export the graph
+     103          31 :         GrB_Index *Ap = NULL ;
+     104          31 :         GrB_Index *Aj = NULL ;
+     105          31 :         void *Ax = NULL ;
+     106             :         GrB_Index Ap_len, Aj_len, Ax_len, nrows, ncols ;
+     107             :         size_t typesize ;
+     108          31 :         OK (GrB_Matrix_nrows (&nrows, G->A)) ;
+     109          31 :         OK (GrB_Matrix_ncols (&ncols, G->A)) ;
+     110             : 
+     111          31 :         OK (LG_check_export (G, &Ap, &Aj, &Ax, &Ap_len, &Aj_len,
+     112             :             &Ax_len, &typesize, msg)) ;
+     113             : 
+     114             :         #if LAGRAPH_SUITESPARSE
+     115             :         #if GxB_IMPLEMENTATION >= GxB_VERSION (6,0,2)
+     116          31 :         printf ("reimport and check result\n") ;
+     117          31 :         OK (GxB_Matrix_import_CSR (&C, atype, nrows, ncols, &Ap, &Aj, &Ax,
+     118             :             Ap_len * sizeof (GrB_Index),
+     119             :             Aj_len * sizeof (GrB_Index),
+     120             :             Ax_len * typesize,
+     121             :             false, true, NULL)) ;
+     122          31 :         OK (GrB_wait (C, GrB_MATERIALIZE)) ;
+     123          31 :         bool ok = false ;
+     124          31 :         OK (LAGraph_Matrix_IsEqual (&ok, G->A, C, msg)) ;
+     125          31 :         TEST_CHECK (ok) ;
+     126          31 :         OK (GrB_free (&C)) ;
+     127             :         #endif
+     128             :         #endif
+     129             : 
+     130          31 :         LAGraph_Free ((void **) &Ap, NULL) ;
+     131          31 :         LAGraph_Free ((void **) &Aj, NULL) ;
+     132          31 :         LAGraph_Free ((void **) &Ax, NULL) ;
+     133          31 :         OK (LAGraph_Delete (&G, msg)) ;
+     134             :     }
+     135             : 
+     136           1 :     LAGraph_Finalize(msg);
+     137           1 : }
+     138             : 
+     139             : //------------------------------------------------------------------------------
+     140             : // test_export_brutal
+     141             : //------------------------------------------------------------------------------
+     142             : 
+     143             : #if LAGRAPH_SUITESPARSE
+     144           1 : void test_export_brutal (void)
+     145             : {
+     146           1 :     OK (LG_brutal_setup (msg)) ;
+     147             : 
+     148           1 :     GrB_Matrix A = NULL, C = NULL ;
+     149             : 
+     150           1 :     for (int k = 0 ; ; k++)
+     151          31 :     {
+     152             : 
+     153             :         // load the adjacency matrix as A
+     154          32 :         const char *aname = files [k].name ;
+     155          32 :         LAGraph_Kind kind = files [k].kind ;
+     156          32 :         if (strlen (aname) == 0) break;
+     157          31 :         TEST_CASE (aname) ;
+     158          31 :         printf ("\nMatrix: %s\n", aname) ;
+     159          31 :         snprintf (filename, LEN, LG_DATA_DIR "%s", aname) ;
+     160          31 :         FILE *f = fopen (filename, "r") ;
+     161          31 :         TEST_CHECK (f != NULL) ;
+     162          31 :         OK (LAGraph_MMRead (&A, f, msg)) ;
+     163          31 :         OK (fclose (f)) ;
+     164          31 :         TEST_MSG ("Loading of adjacency matrix failed") ;
+     165             : 
+     166          31 :         OK (LAGraph_Matrix_TypeName (atype_name, A, msg)) ;
+     167          31 :         OK (LAGraph_TypeFromName (&atype, atype_name, msg)) ;
+     168             : 
+     169             :         // create the graph
+     170          31 :         OK (LAGraph_New (&G, &A, kind, msg)) ;
+     171          31 :         TEST_CHECK (A == NULL) ;    // A has been moved into G->A
+     172             : 
+     173             :         // export the graph
+     174          31 :         GrB_Index *Ap = NULL ;
+     175          31 :         GrB_Index *Aj = NULL ;
+     176          31 :         void *Ax = NULL ;
+     177             :         GrB_Index Ap_len, Aj_len, Ax_len, nrows, ncols ;
+     178             :         size_t typesize ;
+     179          31 :         OK (GrB_Matrix_nrows (&nrows, G->A)) ;
+     180          31 :         OK (GrB_Matrix_ncols (&ncols, G->A)) ;
+     181             : 
+     182         236 :         LG_BRUTAL_BURBLE (LG_check_export (G, &Ap, &Aj, &Ax, &Ap_len, &Aj_len,
+     183             :             &Ax_len, &typesize, msg)) ;
+     184             : 
+     185             :         #if GxB_IMPLEMENTATION >= GxB_VERSION (6,0,2)
+     186          31 :         printf ("reimport and check result\n") ;
+     187          31 :         OK (GxB_Matrix_import_CSR (&C, atype, nrows, ncols, &Ap, &Aj, &Ax,
+     188             :             Ap_len * sizeof (GrB_Index),
+     189             :             Aj_len * sizeof (GrB_Index),
+     190             :             Ax_len * typesize,
+     191             :             false, true, NULL)) ;
+     192          31 :         OK (GrB_wait (C, GrB_MATERIALIZE)) ;
+     193          31 :         bool ok = false ;
+     194          31 :         OK (LAGraph_Matrix_IsEqual (&ok, G->A, C, msg)) ;
+     195          31 :         TEST_CHECK (ok) ;
+     196         272 :         LG_BRUTAL_BURBLE (LAGraph_Matrix_IsEqual (&ok, G->A, C, msg)) ;
+     197          31 :         TEST_CHECK (ok) ;
+     198          31 :         OK (GrB_free (&C)) ;
+     199             :         #endif
+     200             : 
+     201          31 :         LAGraph_Free ((void **) &Ap, NULL) ;
+     202          31 :         LAGraph_Free ((void **) &Aj, NULL) ;
+     203          31 :         LAGraph_Free ((void **) &Ax, NULL) ;
+     204          31 :         OK (LAGraph_Delete (&G, msg)) ;
+     205             :     }
+     206             : 
+     207           1 :     OK (LG_brutal_teardown (msg)) ;
+     208           1 : }
+     209             : #endif
+     210             : 
+     211             : //****************************************************************************
+     212             : //****************************************************************************
+     213             : TEST_LIST = {
+     214             :     {"test_export", test_export },
+     215             :     #if LAGRAPH_SUITESPARSE
+     216             :     {"test_export_brutal", test_export_brutal },
+     217             :     #endif
+     218             :     {NULL, NULL}
+     219             : };
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_fopen.c.func-sort-c.html b/src/test/test_fopen.c.func-sort-c.html new file mode 100644 index 0000000000..70dd988d71 --- /dev/null +++ b/src/test/test_fopen.c.func-sort-c.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_fopen.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_fopen.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1313100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_fopen1
test_fopen_failure1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_fopen.c.func.html b/src/test/test_fopen.c.func.html new file mode 100644 index 0000000000..6a07c70db1 --- /dev/null +++ b/src/test/test_fopen.c.func.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_fopen.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_fopen.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1313100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_fopen1
test_fopen_failure1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_fopen.c.gcov.html b/src/test/test_fopen.c.gcov.html new file mode 100644 index 0000000000..2f5948e33b --- /dev/null +++ b/src/test/test_fopen.c.gcov.html @@ -0,0 +1,128 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_fopen.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_fopen.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1313100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //-----------------------------------------------------------------------------
+       2             : // LAGraph/src/test/test_fopen.c:  test fopen
+       3             : //-----------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //-----------------------------------------------------------------------------
+      17             : 
+      18             : #include "LAGraph_test.h"
+      19             : 
+      20             : //-----------------------------------------------------------------------------
+      21             : // test fopen, as an example of how to use LG_SOURCE_DIR
+      22             : //-----------------------------------------------------------------------------
+      23             : 
+      24           1 : void test_fopen(void)
+      25             : {
+      26             :     char buffer [1000] ;
+      27           1 :     printf ("\nLAGraph source directory: [%s]\n", LG_SOURCE_DIR) ;
+      28           1 :     FILE *f = fopen (LG_SOURCE_DIR "/data/A.mtx", "r") ;
+      29           1 :     TEST_CHECK (f != NULL) ;
+      30           1 :     char *r = fgets (buffer, 512, f) ;
+      31           1 :     TEST_CHECK (r != NULL) ;
+      32           1 :     printf ("[%s]\n", buffer) ;
+      33           1 :     fclose (f) ;
+      34           1 : }
+      35             : 
+      36           1 : void test_fopen_failure (void)
+      37             : {
+      38           1 :     FILE *f = fopen ("garbage", "r") ;
+      39           1 :     TEST_CHECK (f == NULL) ;
+      40           1 : }
+      41             : 
+      42             : //-----------------------------------------------------------------------------
+      43             : // run the test
+      44             : //-----------------------------------------------------------------------------
+      45             : 
+      46             : TEST_LIST =
+      47             : {
+      48             :     { "fopen", test_fopen },
+      49             :     { "fopen_failure", test_fopen_failure },
+      50             :     // no brutal test needed
+      51             :     { NULL, NULL }
+      52             : } ;
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_minmax.c.func-sort-c.html b/src/test/test_minmax.c.func-sort-c.html new file mode 100644 index 0000000000..5d653863c0 --- /dev/null +++ b/src/test/test_minmax.c.func-sort-c.html @@ -0,0 +1,96 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_minmax.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_minmax.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:135135100.0 %
Date:2024-08-29 20:08:04Functions:66100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_minmax1
test_minmax_failures1
test_minmax_int641
test_minmax_uint641
setup4
teardown4
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_minmax.c.func.html b/src/test/test_minmax.c.func.html new file mode 100644 index 0000000000..9b28ef428f --- /dev/null +++ b/src/test/test_minmax.c.func.html @@ -0,0 +1,96 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_minmax.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_minmax.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:135135100.0 %
Date:2024-08-29 20:08:04Functions:66100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
setup4
teardown4
test_minmax1
test_minmax_failures1
test_minmax_int641
test_minmax_uint641
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_minmax.c.gcov.html b/src/test/test_minmax.c.gcov.html new file mode 100644 index 0000000000..dafc1782f3 --- /dev/null +++ b/src/test/test_minmax.c.gcov.html @@ -0,0 +1,539 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_minmax.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_minmax.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:135135100.0 %
Date:2024-08-29 20:08:04Functions:66100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph/src/test/test_minmax.c:  test LAGraph_Cached_EMin/EMax
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include "LAGraph_test.h"
+      19             : #include "LG_internal.h"
+      20             : 
+      21             : //------------------------------------------------------------------------------
+      22             : // global variables
+      23             : //------------------------------------------------------------------------------
+      24             : 
+      25             : int status ;
+      26             : GrB_Info info ;
+      27             : char msg [LAGRAPH_MSG_LEN] ;
+      28             : GrB_Matrix A = NULL ;
+      29             : LAGraph_Graph G = NULL ;
+      30             : const char *name ;
+      31             : #define LEN 512
+      32             : char filename [LEN+1] ;
+      33             : char atype_name [LAGRAPH_MAX_NAME_LEN] ;
+      34             : 
+      35             : //------------------------------------------------------------------------------
+      36             : // test matrices
+      37             : //------------------------------------------------------------------------------
+      38             : 
+      39             : typedef struct
+      40             : {
+      41             :     double emin ;
+      42             :     double emax ;
+      43             :     const char *name ;
+      44             : }
+      45             : matrix_info ;
+      46             : 
+      47             : const matrix_info files [ ] =
+      48             : {
+      49             :     //              amin                amax name
+      50             :     {                  1,                  1, "A2.mtx" } ,
+      51             :     {                  1,                  1, "A.mtx" } ,
+      52             :     {      -583929119292,      1191785641270, "bcsstk13.mtx" } ,
+      53             :     {                  1,                  9, "comments_cover.mtx" } ,
+      54             :     {              0.118,              0.754, "comments_full.mtx" } ,
+      55             :     {          -1.863354,           1.863354, "comments_west0067.mtx" } ,
+      56             :     {                  1,                  9, "cover.mtx" } ,
+      57             :     {                  1,                  1, "cover_structure.mtx" } ,
+      58             :     { -5679.837539484813,  4615.532487504805, "cryg2500.mtx" } ,
+      59             :     {                  0,                  0, "empty.mtx" } ,
+      60             :     {              0.118,              0.754, "full.mtx" } ,
+      61             :     {              0.118,              0.754, "full_noheader.mtx" } ,
+      62             :     { 3.9635860919952393, 28.239410400390625, "full_symmetric.mtx" } ,
+      63             :     {                  1,                  1, "jagmesh7.mtx" } ,
+      64             :     {                  1,                  1, "karate.mtx" } ,
+      65             :     {                  1,                  1, "ldbc-cdlp-directed-example.mtx" } ,
+      66             :     {                  1,                  1, "ldbc-cdlp-undirected-example.mtx" } ,
+      67             :     {                  1,                  1, "ldbc-directed-example-bool.mtx" } ,
+      68             :     {                0.1,               0.83, "ldbc-directed-example.mtx" } ,
+      69             :     {                  1,                  1, "ldbc-directed-example-unweighted.mtx" } ,
+      70             :     {                  1,                  1, "ldbc-undirected-example-bool.mtx" } ,
+      71             :     {               0.12,                0.9, "ldbc-undirected-example.mtx" } ,
+      72             :     {                  1,                  1, "ldbc-undirected-example-unweighted.mtx" } ,
+      73             :     {                  1,                  1, "ldbc-wcc-example.mtx" } ,
+      74             :     {           -6283200,           12566400, "LFAT5.mtx" } ,
+      75             :     {           -6283200,           12566400, "LFAT5_two.mtx" } ,
+      76             :     {              -1.06,              2.429, "lp_afiro.mtx" } ,
+      77             :     {                  1,                  1, "lp_afiro_structure.mtx" } ,
+      78             :     {                  0,                  1, "matrix_bool.mtx" } ,
+      79             :     {          -INFINITY,           INFINITY, "matrix_fp32.mtx" } ,
+      80             :     {                  1,                  1, "matrix_fp32_structure.mtx" } ,
+      81             :     {          -INFINITY,           INFINITY, "matrix_fp64.mtx" } ,
+      82             :     {             -32768,              32767, "matrix_int16.mtx" } ,
+      83             :     {      -2147483648.0,         2147483647, "matrix_int32.mtx" } ,
+      84             :     {               -128,                127, "matrix_int8.mtx" } ,
+      85             :     {                  0,              65535, "matrix_uint16.mtx" } ,
+      86             :     {                  0,         4294967295, "matrix_uint32.mtx" } ,
+      87             :     {                  0,                255, "matrix_uint8.mtx" } ,
+      88             :     {                  1,                  1, "msf1.mtx" } ,
+      89             :     {                  1,                  6, "msf2.mtx" } ,
+      90             :     {                  1,                  2, "msf3.mtx" } ,
+      91             :     {        -45777.0931,         22888.5466, "olm1000.mtx" } ,
+      92             :     {                  1,                  1, "pushpull.mtx" } ,
+      93             :     {                  1,                  1, "sample2.mtx" } ,
+      94             :     {                  1,                  1, "sample.mtx" } ,
+      95             :     {          -INFINITY,           INFINITY, "skew_fp32.mtx" } ,
+      96             :     {          -INFINITY,           INFINITY, "skew_fp64.mtx" } ,
+      97             :     {             -30000,              30000, "skew_int16.mtx" } ,
+      98             :     {          -30000000,           30000000, "skew_int32.mtx" } ,
+      99             :     {               -125,                125, "skew_int8.mtx" } ,
+     100             :     {                  1,                  7, "sources_7.mtx" } ,
+     101             :     {                  1,                  1, "structure.mtx" } ,
+     102             :     {                  1,                  9, "test_BF.mtx" } ,
+     103             :     {                  0,                457, "test_FW_1000.mtx" } ,
+     104             :     {                  1,                214, "test_FW_2003.mtx" } ,
+     105             :     {                  1,               5679, "test_FW_2500.mtx" } ,
+     106             :     {                  1,                  1, "tree-example.mtx" } ,
+     107             :     {          -1.863354,           1.863354, "west0067_jumbled.mtx" } ,
+     108             :     {          -1.863354,           1.863354, "west0067.mtx" } ,
+     109             :     {          -1.863354,           1.863354, "west0067_noheader.mtx" } ,
+     110             :     {                  0,       1.4055985944, "zenios.mtx" } ,
+     111             :     {                  0,                  0, "" }
+     112             : } ;
+     113             : 
+     114             : // additional files (cast to double is not accurate):
+     115             : 
+     116             : typedef struct
+     117             : {
+     118             :     int64_t emin ;
+     119             :     int64_t emax ;
+     120             :     const char *name ;
+     121             : }
+     122             : matrix_info_int64 ;
+     123             : 
+     124             : const matrix_info_int64 files_int64 [ ] =
+     125             : {
+     126             :     { -9223372036854775800L,  9223372036854775807L, "matrix_int64.mtx" } ,
+     127             :     { -9223372036854775807L,  9223372036854775807L, "skew_int64.mtx" } ,
+     128             :     {                     0,                     0, "" }
+     129             : } ;
+     130             : 
+     131             : typedef struct
+     132             : {
+     133             :     uint64_t emin ;
+     134             :     uint64_t emax ;
+     135             :     const char *name ;
+     136             : }
+     137             : matrix_info_uint64 ;
+     138             : 
+     139             : const matrix_info_uint64 files_uint64 [ ] =
+     140             : {
+     141             :     {                    0, 18446744073709551615UL, "matrix_uint64.mtx" } ,
+     142             :     {                    0,                      0, "" }
+     143             : } ;
+     144             : 
+     145             : //------------------------------------------------------------------------------
+     146             : // setup: start a test
+     147             : //------------------------------------------------------------------------------
+     148             : 
+     149           4 : void setup (void)
+     150             : {
+     151           4 :     OK (LAGraph_Init (msg)) ;
+     152           4 : }
+     153             : 
+     154             : //------------------------------------------------------------------------------
+     155             : // teardown: finalize a test
+     156             : //------------------------------------------------------------------------------
+     157             : 
+     158           4 : void teardown (void)
+     159             : {
+     160           4 :     OK (LAGraph_Finalize (msg)) ;
+     161           4 : }
+     162             : 
+     163             : //------------------------------------------------------------------------------
+     164             : // test_minmax: read a set of matrices and compute min/max
+     165             : //------------------------------------------------------------------------------
+     166             : 
+     167           1 : void test_minmax (void)
+     168             : {
+     169             : 
+     170             :     //--------------------------------------------------------------------------
+     171             :     // start up the test
+     172             :     //--------------------------------------------------------------------------
+     173             : 
+     174           1 :     setup ( ) ;
+     175             : 
+     176           1 :     for (int k = 0 ; ; k++)
+     177          61 :     {
+     178             : 
+     179             :         //----------------------------------------------------------------------
+     180             :         // load in the kth file and create the graph G
+     181             :         //----------------------------------------------------------------------
+     182             : 
+     183          62 :         const char *aname = files [k].name ;
+     184          62 :         if (strlen (aname) == 0) break;
+     185          61 :         TEST_CASE (aname) ;
+     186          61 :         printf ("\n============= %2d: %s\n", k, aname) ;
+     187          61 :         snprintf (filename, LEN, LG_DATA_DIR "%s", aname) ;
+     188          61 :         FILE *f = fopen (filename, "rb") ;
+     189          61 :         TEST_CHECK (f != NULL) ;
+     190          61 :         OK (LAGraph_MMRead (&A, f, msg)) ;
+     191          61 :         OK (fclose (f)) ;
+     192          61 :         TEST_MSG ("Failed to load %s\n", aname) ;
+     193             :         GrB_Index nvals ;
+     194          61 :         OK (GrB_Matrix_nvals (&nvals, A)) ;
+     195          61 :         OK (LAGraph_New (&G, &A, LAGraph_ADJACENCY_DIRECTED, msg)) ;
+     196             : 
+     197             :         //----------------------------------------------------------------------
+     198             :         // compute emin and emax
+     199             :         //----------------------------------------------------------------------
+     200             : 
+     201          61 :         OK (LAGraph_Cached_EMin (G, msg)) ;
+     202          61 :         TEST_CHECK (G->emin_state == LAGraph_VALUE) ;
+     203          61 :         OK (LAGraph_Cached_EMax (G, msg)) ;
+     204          61 :         TEST_CHECK (G->emax_state == LAGraph_VALUE) ;
+     205             : 
+     206             :         //----------------------------------------------------------------------
+     207             :         // check the result
+     208             :         //----------------------------------------------------------------------
+     209             : 
+     210          61 :         double emin1 = files [k].emin ;
+     211          61 :         double emax1 = files [k].emax ;
+     212          61 :         double emin2 = 0 ;
+     213          61 :         double emax2 = 0 ;
+     214             : 
+     215          61 :         printf ("min/max as GrB_Scalars:\n") ;
+     216          61 :         GxB_print (G->emin, 3) ;
+     217          61 :         GxB_print (G->emax, 3) ;
+     218             : 
+     219             :         int result ;
+     220          61 :         result = GrB_Scalar_extractElement_FP64 (&emin2, G->emin) ;
+     221          61 :         printf ("min: %g %g err %g\n", emin1, emin2, emin1 - emin2) ;
+     222          61 :         if (nvals == 0)
+     223             :         {
+     224           1 :             TEST_CHECK (result == GrB_NO_VALUE) ;
+     225             :         }
+     226             :         else
+     227             :         {
+     228          60 :             TEST_CHECK (result == GrB_SUCCESS) ;
+     229             :         }
+     230             : 
+     231             :         #if 0
+     232             :         if (emin1 != emin2)
+     233             :         {
+     234             :             // failure on MSVC, OpenMP
+     235             :             // https://github.com/DrTimothyAldenDavis/SuiteSparse/actions/runs/6763376325/job/18380420493?pr=503
+     236             :             // now fixed.
+     237             :             printf ("Test failure, k: %d name: %s\n", k, aname) ;
+     238             :             printf ("emin1: %30.20g\n", emin1) ;
+     239             :             printf ("emin2: %30.20g\n", emin2) ;
+     240             :             OK (LAGraph_Matrix_Print (G->A, 5, stdout, msg)) ;
+     241             : 
+     242             :             // extract as int64:
+     243             :             int64_t emin2_int64 = 0 ;
+     244             :             int64_t emax2_int64 = 0 ;
+     245             :             GrB_Scalar_extractElement_INT64 (&emin2_int64, G->emin) ;
+     246             :             GrB_Scalar_extractElement_INT64 (&emax2_int64, G->emax) ;
+     247             :             printf ("emin2 int64: %" PRId64 "\n", emin2_int64) ;
+     248             :             printf ("emax2 int64: %" PRId64 "\n", emax2_int64) ;
+     249             : 
+     250             :         }
+     251             :         #endif
+     252             : 
+     253          61 :         TEST_CHECK (emin1 == emin2) ;
+     254             : 
+     255          61 :         result = GrB_Scalar_extractElement_FP64 (&emax2, G->emax) ;
+     256          61 :         printf ("max: %g %g err %g\n", emax1, emax2, emax1 - emax2) ;
+     257          61 :         if (nvals == 0)
+     258             :         {
+     259           1 :             printf ("no entries\n") ;
+     260           1 :             TEST_CHECK (result == GrB_NO_VALUE) ;
+     261             :         }
+     262             :         else
+     263             :         {
+     264          60 :             TEST_CHECK (result == GrB_SUCCESS) ;
+     265             :         }
+     266          61 :         TEST_CHECK (emax1 == emax2) ;
+     267             : 
+     268          61 :         OK (LAGraph_Delete (&G, msg)) ;
+     269             :     }
+     270             : 
+     271             :     //--------------------------------------------------------------------------
+     272             :     // finish the test
+     273             :     //--------------------------------------------------------------------------
+     274             : 
+     275           1 :     teardown ( ) ;
+     276           1 : }
+     277             : 
+     278             : //------------------------------------------------------------------------------
+     279             : // test_minmax_int64: read a set of matrices and compute min/max
+     280             : //------------------------------------------------------------------------------
+     281             : 
+     282           1 : void test_minmax_int64 (void)
+     283             : {
+     284             : 
+     285             :     //--------------------------------------------------------------------------
+     286             :     // start up the test
+     287             :     //--------------------------------------------------------------------------
+     288             : 
+     289           1 :     setup ( ) ;
+     290             : 
+     291           1 :     for (int k = 0 ; ; k++)
+     292           2 :     {
+     293             : 
+     294             :         //----------------------------------------------------------------------
+     295             :         // load in the kth file and create the graph G
+     296             :         //----------------------------------------------------------------------
+     297             : 
+     298           3 :         const char *aname = files_int64 [k].name ;
+     299           3 :         if (strlen (aname) == 0) break;
+     300           2 :         TEST_CASE (aname) ;
+     301           2 :         printf ("\n============= %2d: %s\n", k, aname) ;
+     302           2 :         snprintf (filename, LEN, LG_DATA_DIR "%s", aname) ;
+     303           2 :         FILE *f = fopen (filename, "rb") ;
+     304           2 :         TEST_CHECK (f != NULL) ;
+     305           2 :         OK (LAGraph_MMRead (&A, f, msg)) ;
+     306           2 :         OK (fclose (f)) ;
+     307           2 :         TEST_MSG ("Failed to load %s\n", aname) ;
+     308             :         GrB_Index nvals ;
+     309           2 :         OK (GrB_Matrix_nvals (&nvals, A)) ;
+     310           2 :         OK (LAGraph_New (&G, &A, LAGraph_ADJACENCY_DIRECTED, msg)) ;
+     311             : 
+     312           6 :         for (int trial = 1 ; trial <= 2 ; trial++)
+     313             :         {
+     314             : 
+     315             :             //------------------------------------------------------------------
+     316             :             // compute emin and emax
+     317             :             //------------------------------------------------------------------
+     318             : 
+     319           4 :             OK (LAGraph_Cached_EMin (G, msg)) ;
+     320           4 :             TEST_CHECK (G->emin_state == LAGraph_VALUE) ;
+     321           4 :             OK (LAGraph_Cached_EMax (G, msg)) ;
+     322           4 :             TEST_CHECK (G->emax_state == LAGraph_VALUE) ;
+     323             : 
+     324             :             //------------------------------------------------------------------
+     325             :             // check the result
+     326             :             //------------------------------------------------------------------
+     327             : 
+     328           4 :             int64_t emin1 = files_int64 [k].emin ;
+     329           4 :             int64_t emax1 = files_int64 [k].emax ;
+     330           4 :             int64_t emin2 = 0 ;
+     331           4 :             int64_t emax2 = 0 ;
+     332             : 
+     333             :             int result ;
+     334           4 :             result = GrB_Scalar_extractElement_INT64 (&emin2, G->emin) ;
+     335           4 :             printf ("min (int64): %" PRId64" %" PRId64 "\n", emin1, emin2) ;
+     336           4 :             TEST_CHECK (result == GrB_SUCCESS) ;
+     337           4 :             TEST_CHECK (emin1 == emin2) ;
+     338             : 
+     339           4 :             result = GrB_Scalar_extractElement_INT64 (&emax2, G->emax) ;
+     340           4 :             printf ("max (int64): %" PRId64" %" PRId64 "\n", emax1, emax2) ;
+     341           4 :             TEST_CHECK (result == GrB_SUCCESS) ;
+     342           4 :             TEST_CHECK (emax1 == emax2) ;
+     343             :         }
+     344             : 
+     345           2 :         OK (LAGraph_Delete (&G, msg)) ;
+     346             :     }
+     347             : 
+     348             :     //--------------------------------------------------------------------------
+     349             :     // finish the test
+     350             :     //--------------------------------------------------------------------------
+     351             : 
+     352           1 :     teardown ( ) ;
+     353           1 : }
+     354             : 
+     355             : //------------------------------------------------------------------------------
+     356             : // test_minmax_uint64: read a set of matrices and compute min/max
+     357             : //------------------------------------------------------------------------------
+     358             : 
+     359           1 : void test_minmax_uint64 (void)
+     360             : {
+     361             : 
+     362             :     //--------------------------------------------------------------------------
+     363             :     // start up the test
+     364             :     //--------------------------------------------------------------------------
+     365             : 
+     366           1 :     setup ( ) ;
+     367             : 
+     368           1 :     for (int k = 0 ; ; k++)
+     369           1 :     {
+     370             : 
+     371             :         //----------------------------------------------------------------------
+     372             :         // load in the kth file and create the graph G
+     373             :         //----------------------------------------------------------------------
+     374             : 
+     375           2 :         const char *aname = files_uint64 [k].name ;
+     376           2 :         if (strlen (aname) == 0) break;
+     377           1 :         TEST_CASE (aname) ;
+     378           1 :         printf ("\n============= %2d: %s\n", k, aname) ;
+     379           1 :         snprintf (filename, LEN, LG_DATA_DIR "%s", aname) ;
+     380           1 :         FILE *f = fopen (filename, "rb") ;
+     381           1 :         TEST_CHECK (f != NULL) ;
+     382           1 :         OK (LAGraph_MMRead (&A, f, msg)) ;
+     383           1 :         OK (fclose (f)) ;
+     384           1 :         TEST_MSG ("Failed to load %s\n", aname) ;
+     385             :         GrB_Index nvals ;
+     386           1 :         OK (GrB_Matrix_nvals (&nvals, A)) ;
+     387           1 :         OK (LAGraph_New (&G, &A, LAGraph_ADJACENCY_DIRECTED, msg)) ;
+     388             : 
+     389             :         //----------------------------------------------------------------------
+     390             :         // compute emin and emax
+     391             :         //----------------------------------------------------------------------
+     392             : 
+     393           1 :         OK (LAGraph_Cached_EMin (G, msg)) ;
+     394           1 :         TEST_CHECK (G->emin_state == LAGraph_VALUE) ;
+     395           1 :         OK (LAGraph_Cached_EMax (G, msg)) ;
+     396           1 :         TEST_CHECK (G->emax_state == LAGraph_VALUE) ;
+     397             : 
+     398             :         //----------------------------------------------------------------------
+     399             :         // check the result
+     400             :         //----------------------------------------------------------------------
+     401             : 
+     402           1 :         uint64_t emin1 = files_uint64 [k].emin ;
+     403           1 :         uint64_t emax1 = files_uint64 [k].emax ;
+     404           1 :         uint64_t emin2 = 0 ;
+     405           1 :         uint64_t emax2 = 0 ;
+     406             : 
+     407             :         int result ;
+     408           1 :         result = GrB_Scalar_extractElement_UINT64 (&emin2, G->emin) ;
+     409           1 :         printf ("min (uint64): %" PRIu64" %" PRIu64 "\n", emin1, emin2) ;
+     410           1 :         TEST_CHECK (result == GrB_SUCCESS) ;
+     411           1 :         TEST_CHECK (emin1 == emin2) ;
+     412             : 
+     413           1 :         result = GrB_Scalar_extractElement_UINT64 (&emax2, G->emax) ;
+     414           1 :         printf ("max (uint64): %" PRIu64" %" PRIu64 "\n", emax1, emax2) ;
+     415           1 :         TEST_CHECK (result == GrB_SUCCESS) ;
+     416           1 :         TEST_CHECK (emax1 == emax2) ;
+     417             : 
+     418           1 :         OK (LAGraph_Delete (&G, msg)) ;
+     419             :     }
+     420             : 
+     421             :     //--------------------------------------------------------------------------
+     422             :     // finish the test
+     423             :     //--------------------------------------------------------------------------
+     424             : 
+     425           1 :     teardown ( ) ;
+     426           1 : }
+     427             : 
+     428             : //-----------------------------------------------------------------------------
+     429             : // test_minmax_failures
+     430             : //-----------------------------------------------------------------------------
+     431             : 
+     432             : typedef int myint ;
+     433             : 
+     434           1 : void test_minmax_failures (void)
+     435             : {
+     436           1 :     setup ( ) ;
+     437             :     GrB_Type MyInt ;
+     438           1 :     OK (GrB_Type_new (&MyInt, sizeof (myint))) ;
+     439           1 :     OK (GrB_Matrix_new (&A, MyInt, 4, 4)) ;
+     440           1 :     OK (LAGraph_New (&G, &A, LAGraph_ADJACENCY_DIRECTED, msg)) ;
+     441           1 :     int result = LAGraph_Cached_EMax (G, msg) ;
+     442           1 :     printf ("\nresult: %d msg: %s\n", result, msg) ;
+     443           1 :     TEST_CHECK (result == GrB_NOT_IMPLEMENTED) ;
+     444           1 :     result = LAGraph_Cached_EMin (G, msg) ;
+     445           1 :     printf ("result: %d msg: %s\n", result, msg) ;
+     446           1 :     TEST_CHECK (result == GrB_NOT_IMPLEMENTED) ;
+     447           1 :     OK (GrB_free (&MyInt)) ;
+     448           1 :     OK (LAGraph_Delete (&G, msg)) ;
+     449           1 :     teardown ( ) ;
+     450           1 : }
+     451             : 
+     452             : //-----------------------------------------------------------------------------
+     453             : // TEST_LIST: the list of tasks for this entire test
+     454             : //-----------------------------------------------------------------------------
+     455             : 
+     456             : TEST_LIST =
+     457             : {
+     458             :     { "test_minmax", test_minmax },
+     459             :     { "test_minmax_int64", test_minmax_int64 },
+     460             :     { "test_minmax_uint64", test_minmax_uint64 },
+     461             :     { "test_minmax_failures", test_minmax_failures },
+     462             :     { NULL, NULL }
+     463             : } ;
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_vector.c.func-sort-c.html b/src/test/test_vector.c.func-sort-c.html new file mode 100644 index 0000000000..1424aa91f2 --- /dev/null +++ b/src/test/test_vector.c.func-sort-c.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_vector.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_vector.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3939100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_vector1
test_vector_brutal1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_vector.c.func.html b/src/test/test_vector.c.func.html new file mode 100644 index 0000000000..b564952da7 --- /dev/null +++ b/src/test/test_vector.c.func.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_vector.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_vector.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3939100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
test_vector1
test_vector_brutal1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/test/test_vector.c.gcov.html b/src/test/test_vector.c.gcov.html new file mode 100644 index 0000000000..d7c69ff21a --- /dev/null +++ b/src/test/test_vector.c.gcov.html @@ -0,0 +1,187 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/test/test_vector.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/test - test_vector.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3939100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph/src/test/test_vector.c:  test LG_check_vector
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include "LAGraph_test.h"
+      19             : 
+      20             : //------------------------------------------------------------------------------
+      21             : // global variables
+      22             : //------------------------------------------------------------------------------
+      23             : 
+      24             : GrB_Vector X = NULL ;
+      25             : int64_t *x = NULL ;
+      26             : GrB_Index n = 10000 ;
+      27             : int64_t missing = 42 ;
+      28             : char msg [LAGRAPH_MSG_LEN] ;
+      29             : 
+      30             : //------------------------------------------------------------------------------
+      31             : // test_vector
+      32             : //------------------------------------------------------------------------------
+      33             : 
+      34           1 : void test_vector (void)
+      35             : {
+      36           1 :     OK (LAGraph_Init (msg)) ;
+      37           1 :     OK (GrB_Vector_new (&X, GrB_INT64, n)) ;
+      38          11 :     for (int i = 0 ; i < 10 ; i++)
+      39             :     {
+      40          10 :         OK (GrB_Vector_setElement (X, i, i)) ;
+      41             :     }
+      42           1 :     OK (LAGraph_Malloc ((void **) &x, n, sizeof (int64_t), msg)) ;
+      43           1 :     OK (LG_check_vector (x, X, n, missing)) ;
+      44       10001 :     for (int i = 0 ; i < n ; i++)
+      45             :     {
+      46       10000 :         TEST_CHECK (x [i] == ((i < 10) ? i : missing)) ;
+      47             :     }
+      48           1 :     OK (GrB_free (&X)) ;
+      49           1 :     OK (LAGraph_Free ((void **) &x, NULL)) ;
+      50           1 :     OK (LAGraph_Finalize (msg)) ;
+      51           1 : }
+      52             : 
+      53             : //------------------------------------------------------------------------------
+      54             : // test_vector_brutal
+      55             : //------------------------------------------------------------------------------
+      56             : 
+      57             : #if LAGRAPH_SUITESPARSE
+      58           1 : void test_vector_brutal (void)
+      59             : {
+      60           1 :     OK (LG_brutal_setup (msg)) ;
+      61           1 :     printf ("\n") ;
+      62             : 
+      63           1 :     OK (LAGraph_Malloc ((void **) &x, n, sizeof (int64_t), msg)) ;
+      64             : 
+      65           1 :     for (int nbrutal = 0 ; ; nbrutal++)
+      66          21 :     {
+      67             :         /* allow for only nbrutal mallocs before 'failing' */
+      68          22 :         LG_brutal = nbrutal ;
+      69             :         /* try the method with brutal malloc */
+      70          22 :         GrB_free (&X) ;
+      71          22 :         int brutal_result = GrB_Vector_new (&X, GrB_INT64, n) ;
+      72          22 :         if (brutal_result != GrB_SUCCESS) continue ;
+      73         127 :         for (int i = 0 ; i < 10 ; i++)
+      74             :         {
+      75         117 :             brutal_result = GrB_Vector_setElement (X, i, i) ;
+      76         117 :             if (brutal_result != GrB_SUCCESS) break ;
+      77             :         }
+      78          20 :         if (brutal_result != GrB_SUCCESS) continue ;
+      79          10 :         brutal_result = LG_check_vector (x, X, n, missing) ;
+      80          10 :         if (brutal_result >= 0)
+      81             :         {
+      82             :             /* the method finally succeeded */
+      83           1 :             printf ("Finally: %d\n", nbrutal) ;
+      84           1 :             break ;
+      85             :         }
+      86           9 :         if (nbrutal > 10000) { printf ("Infinite!\n") ; abort ( ) ; }
+      87             :     }
+      88           1 :     LG_brutal = -1 ;  /* turn off brutal mallocs */
+      89             : 
+      90       10001 :     for (int i = 0 ; i < n ; i++)
+      91             :     {
+      92       10000 :         TEST_CHECK (x [i] == ((i < 10) ? i : missing)) ;
+      93             :     }
+      94           1 :     OK (GrB_free (&X)) ;
+      95           1 :     OK (LAGraph_Free ((void **) &x, NULL)) ;
+      96           1 :     OK (LG_brutal_teardown (msg)) ;
+      97           1 : }
+      98             : #endif
+      99             : 
+     100             : //-----------------------------------------------------------------------------
+     101             : // TEST_LIST: the list of tasks for this entire test
+     102             : //-----------------------------------------------------------------------------
+     103             : 
+     104             : TEST_LIST =
+     105             : {
+     106             :     { "vector", test_vector },
+     107             :     #if LAGRAPH_SUITESPARSE
+     108             :     { "vector_brutal", test_vector_brutal },
+     109             :     #endif
+     110             :     { NULL, NULL }
+     111             : } ;
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGr_Init.c.func-sort-c.html b/src/utility/LAGr_Init.c.func-sort-c.html new file mode 100644 index 0000000000..6a1cde8497 --- /dev/null +++ b/src/utility/LAGr_Init.c.func-sort-c.html @@ -0,0 +1,84 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGr_Init.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGr_Init.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:6262100.0 %
Date:2024-08-29 20:08:04Functions:33100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_set_LAGr_Init_has_been_called184
LAGr_Init187
LG_get_LAGr_Init_has_been_called242
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGr_Init.c.func.html b/src/utility/LAGr_Init.c.func.html new file mode 100644 index 0000000000..e034e50fe4 --- /dev/null +++ b/src/utility/LAGr_Init.c.func.html @@ -0,0 +1,84 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGr_Init.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGr_Init.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:6262100.0 %
Date:2024-08-29 20:08:04Functions:33100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGr_Init187
LG_get_LAGr_Init_has_been_called242
LG_set_LAGr_Init_has_been_called184
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGr_Init.c.gcov.html b/src/utility/LAGr_Init.c.gcov.html new file mode 100644 index 0000000000..511fed15b1 --- /dev/null +++ b/src/utility/LAGr_Init.c.gcov.html @@ -0,0 +1,407 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGr_Init.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGr_Init.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:6262100.0 %
Date:2024-08-29 20:08:04Functions:33100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGr_Init: start GraphBLAS and LAGraph, and set malloc/etc functions
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2023 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #define LG_FREE_ALL ;
+      19             : 
+      20             : #include "LG_internal.h"
+      21             : 
+      22             : //------------------------------------------------------------------------------
+      23             : // LG_LAGr_Init_has_been_called: a static value only accessible within this file
+      24             : //------------------------------------------------------------------------------
+      25             : 
+      26             : // LG_LAGr_Init_has_been_called indicates if LAGr_Init has been called.
+      27             : // LAGr_Init (or LAGraph_Init) can be called only once, even after
+      28             : // LAGraph_Finalize has been called.  For testing purposes, the flag can be
+      29             : // cleared by src/test/test_Xinit, to allow LAGr_Init or LAGraph_Init to be
+      30             : // called again.
+      31             : 
+      32             : static bool LG_LAGr_Init_has_been_called = false ;
+      33             : 
+      34             : // LG_LAGr_Init_has_been_called is only modified or accessed by the following
+      35             : // two routines (even in this file).  The two functions are made accessible via
+      36             : // LAGRAPH_PUBLIC, only for testing purposes by src/test/test_Xinit.c.
+      37             : 
+      38             : LAGRAPH_PUBLIC void LG_set_LAGr_Init_has_been_called (bool setting) ;
+      39             : LAGRAPH_PUBLIC bool LG_get_LAGr_Init_has_been_called (void) ;
+      40             : 
+      41             : LAGRAPH_PUBLIC
+      42         184 : void LG_set_LAGr_Init_has_been_called (bool setting)
+      43             : {
+      44         184 :     LG_LAGr_Init_has_been_called = setting ;
+      45         184 : }
+      46             : 
+      47             : LAGRAPH_PUBLIC
+      48         242 : bool LG_get_LAGr_Init_has_been_called (void)
+      49             : {
+      50         242 :     return (LG_LAGr_Init_has_been_called) ;
+      51             : }
+      52             : 
+      53             : //------------------------------------------------------------------------------
+      54             : // LAGraph global objects
+      55             : //------------------------------------------------------------------------------
+      56             : 
+      57             : // LAGraph_plus_first_T: using the GrB_PLUS_MONOID_T monoid and the
+      58             : // corresponding GrB_FIRST_T multiplicative operator.
+      59             : LAGRAPH_PUBLIC GrB_Semiring LAGraph_plus_first_int8   = NULL ;
+      60             : LAGRAPH_PUBLIC GrB_Semiring LAGraph_plus_first_int16  = NULL ;
+      61             : LAGRAPH_PUBLIC GrB_Semiring LAGraph_plus_first_int32  = NULL ;
+      62             : LAGRAPH_PUBLIC GrB_Semiring LAGraph_plus_first_int64  = NULL ;
+      63             : LAGRAPH_PUBLIC GrB_Semiring LAGraph_plus_first_uint8  = NULL ;
+      64             : LAGRAPH_PUBLIC GrB_Semiring LAGraph_plus_first_uint16 = NULL ;
+      65             : LAGRAPH_PUBLIC GrB_Semiring LAGraph_plus_first_uint32 = NULL ;
+      66             : LAGRAPH_PUBLIC GrB_Semiring LAGraph_plus_first_uint64 = NULL ;
+      67             : LAGRAPH_PUBLIC GrB_Semiring LAGraph_plus_first_fp32   = NULL ;
+      68             : LAGRAPH_PUBLIC GrB_Semiring LAGraph_plus_first_fp64   = NULL ;
+      69             : 
+      70             : // LAGraph_plus_second_T: using the GrB_PLUS_MONOID_T monoid and the
+      71             : // corresponding GrB_SECOND_T multiplicative operator.
+      72             : LAGRAPH_PUBLIC GrB_Semiring LAGraph_plus_second_int8   = NULL ;
+      73             : LAGRAPH_PUBLIC GrB_Semiring LAGraph_plus_second_int16  = NULL ;
+      74             : LAGRAPH_PUBLIC GrB_Semiring LAGraph_plus_second_int32  = NULL ;
+      75             : LAGRAPH_PUBLIC GrB_Semiring LAGraph_plus_second_int64  = NULL ;
+      76             : LAGRAPH_PUBLIC GrB_Semiring LAGraph_plus_second_uint8  = NULL ;
+      77             : LAGRAPH_PUBLIC GrB_Semiring LAGraph_plus_second_uint16 = NULL ;
+      78             : LAGRAPH_PUBLIC GrB_Semiring LAGraph_plus_second_uint32 = NULL ;
+      79             : LAGRAPH_PUBLIC GrB_Semiring LAGraph_plus_second_uint64 = NULL ;
+      80             : LAGRAPH_PUBLIC GrB_Semiring LAGraph_plus_second_fp32   = NULL ;
+      81             : LAGRAPH_PUBLIC GrB_Semiring LAGraph_plus_second_fp64   = NULL ;
+      82             : 
+      83             : // LAGraph_plus_one_T: using the GrB_PLUS_MONOID_T monoid and the
+      84             : // corresponding GrB_ONEB_T multiplicative operator.
+      85             : LAGRAPH_PUBLIC GrB_Semiring LAGraph_plus_one_int8   = NULL ;
+      86             : LAGRAPH_PUBLIC GrB_Semiring LAGraph_plus_one_int16  = NULL ;
+      87             : LAGRAPH_PUBLIC GrB_Semiring LAGraph_plus_one_int32  = NULL ;
+      88             : LAGRAPH_PUBLIC GrB_Semiring LAGraph_plus_one_int64  = NULL ;
+      89             : LAGRAPH_PUBLIC GrB_Semiring LAGraph_plus_one_uint8  = NULL ;
+      90             : LAGRAPH_PUBLIC GrB_Semiring LAGraph_plus_one_uint16 = NULL ;
+      91             : LAGRAPH_PUBLIC GrB_Semiring LAGraph_plus_one_uint32 = NULL ;
+      92             : LAGRAPH_PUBLIC GrB_Semiring LAGraph_plus_one_uint64 = NULL ;
+      93             : LAGRAPH_PUBLIC GrB_Semiring LAGraph_plus_one_fp32   = NULL ;
+      94             : LAGRAPH_PUBLIC GrB_Semiring LAGraph_plus_one_fp64   = NULL ;
+      95             : 
+      96             : 
+      97             : // use LAGraph_any_one_bool, etc
+      98             : 
+      99             : // LAGraph_any_one_T: using the GrB_MIN_MONOID_T for non-boolean types
+     100             : // or GrB_LOR_MONOID_BOOL for boolean, and the GrB_ONEB_T multiplicative op.
+     101             : LAGRAPH_PUBLIC GrB_Semiring LAGraph_any_one_bool   = NULL ;
+     102             : LAGRAPH_PUBLIC GrB_Semiring LAGraph_any_one_int8   = NULL ;
+     103             : LAGRAPH_PUBLIC GrB_Semiring LAGraph_any_one_int16  = NULL ;
+     104             : LAGRAPH_PUBLIC GrB_Semiring LAGraph_any_one_int32  = NULL ;
+     105             : LAGRAPH_PUBLIC GrB_Semiring LAGraph_any_one_int64  = NULL ;
+     106             : LAGRAPH_PUBLIC GrB_Semiring LAGraph_any_one_uint8  = NULL ;
+     107             : LAGRAPH_PUBLIC GrB_Semiring LAGraph_any_one_uint16 = NULL ;
+     108             : LAGRAPH_PUBLIC GrB_Semiring LAGraph_any_one_uint32 = NULL ;
+     109             : LAGRAPH_PUBLIC GrB_Semiring LAGraph_any_one_uint64 = NULL ;
+     110             : LAGRAPH_PUBLIC GrB_Semiring LAGraph_any_one_fp32   = NULL ;
+     111             : LAGRAPH_PUBLIC GrB_Semiring LAGraph_any_one_fp64   = NULL ;
+     112             : 
+     113             : //------------------------------------------------------------------------------
+     114             : // LAGr_Init
+     115             : //------------------------------------------------------------------------------
+     116             : 
+     117             : LAGRAPH_PUBLIC
+     118         187 : int LAGr_Init
+     119             : (
+     120             :     // input:
+     121             :     GrB_Mode mode,      // mode for GrB_Init or GxB_Init
+     122             :     void * (* user_malloc_function  ) (size_t),
+     123             :     void * (* user_calloc_function  ) (size_t, size_t),
+     124             :     void * (* user_realloc_function ) (void *, size_t),
+     125             :     void   (* user_free_function    ) (void *),
+     126             :     char *msg
+     127             : )
+     128             : {
+     129             : 
+     130             :     //--------------------------------------------------------------------------
+     131             :     // check inputs
+     132             :     //--------------------------------------------------------------------------
+     133             : 
+     134             :     // malloc and free are required; calloc and realloc are optional
+     135         187 :     LG_CLEAR_MSG ;
+     136         187 :     LG_ASSERT (user_malloc_function != NULL, GrB_NULL_POINTER) ;
+     137         185 :     LG_ASSERT (user_free_function   != NULL, GrB_NULL_POINTER) ;
+     138             :     GrB_Info info ;
+     139             : 
+     140             :     // ensure LAGr_Init has not already been called
+     141         184 :     LG_ASSERT_MSG (!LG_get_LAGr_Init_has_been_called ( ), GrB_INVALID_VALUE,
+     142             :         "LAGr*_Init can only be called once") ;
+     143             : 
+     144             :     //--------------------------------------------------------------------------
+     145             :     // start GraphBLAS
+     146             :     //--------------------------------------------------------------------------
+     147             : 
+     148             :     #if LAGRAPH_SUITESPARSE
+     149             : 
+     150         182 :         info = GxB_init (mode,
+     151             :             user_malloc_function,
+     152             :             user_calloc_function,
+     153             :             user_realloc_function,
+     154             :             user_free_function) ;
+     155             : 
+     156             :     #else
+     157             : 
+     158             :         // GxB_init is not available.  Use GrB_init instead.
+     159             :         info = GrB_init (mode) ;
+     160             : 
+     161             :     #endif
+     162             : 
+     163         182 :     LG_ASSERT_MSG (info == GrB_SUCCESS || info == GrB_INVALID_VALUE, info,
+     164             :         "failed to initialize GraphBLAS") ;
+     165             : 
+     166             :     #undef  LG_FREE_ALL
+     167             :     #define LG_FREE_ALL             \
+     168             :     {                               \
+     169             :         LAGraph_Finalize (msg) ;    \
+     170             :     }
+     171             : 
+     172             :     //--------------------------------------------------------------------------
+     173             :     // save the memory management pointers in global LAGraph space
+     174             :     //--------------------------------------------------------------------------
+     175             : 
+     176         172 :     LAGraph_Malloc_function  = user_malloc_function ;
+     177         172 :     LAGraph_Calloc_function  = user_calloc_function ;
+     178         172 :     LAGraph_Realloc_function = user_realloc_function ;
+     179         172 :     LAGraph_Free_function    = user_free_function ;
+     180             : 
+     181             :     //--------------------------------------------------------------------------
+     182             :     // set # of LAGraph threads
+     183             :     //--------------------------------------------------------------------------
+     184             : 
+     185         172 :     LG_nthreads_outer = 1 ;             // for LAGraph itself, if nested
+     186             :                                         // regions call GraphBLAS
+     187             :     #ifdef _OPENMP
+     188             :     LG_nthreads_inner = omp_get_max_threads ( ) ; // for lower-level parallelism
+     189             :     #else
+     190         172 :     LG_nthreads_inner = 1 ;
+     191             :     #endif
+     192             : 
+     193             :     #if LAGRAPH_SUITESPARSE
+     194             :     {
+     195         172 :         GRB_TRY (GxB_set (GxB_NTHREADS, LG_nthreads_inner)) ;
+     196             :     }
+     197             :     #endif
+     198             : 
+     199             :     //--------------------------------------------------------------------------
+     200             :     // create global objects
+     201             :     //--------------------------------------------------------------------------
+     202             : 
+     203             :     // LAGraph_plus_first_T: using the GrB_PLUS_MONOID_T monoid and the
+     204             :     // GrB_FIRST_T multiplicative operator.  These semirings compute C=A*B
+     205             :     // where only the structure of B is accessed.  In MATLAB, this can be
+     206             :     // written as:
+     207             :     //
+     208             :     //      C = A * spones (B)
+     209             : 
+     210         172 :     GRB_TRY (GrB_Semiring_new (&LAGraph_plus_first_int8,
+     211             :         GrB_PLUS_MONOID_INT8  , GrB_FIRST_INT8  )) ;
+     212         171 :     GRB_TRY (GrB_Semiring_new (&LAGraph_plus_first_int16,
+     213             :         GrB_PLUS_MONOID_INT16 , GrB_FIRST_INT16 )) ;
+     214         170 :     GRB_TRY (GrB_Semiring_new (&LAGraph_plus_first_int32,
+     215             :         GrB_PLUS_MONOID_INT32 , GrB_FIRST_INT32 )) ;
+     216         169 :     GRB_TRY (GrB_Semiring_new (&LAGraph_plus_first_int64,
+     217             :         GrB_PLUS_MONOID_INT64 , GrB_FIRST_INT64 )) ;
+     218         168 :     GRB_TRY (GrB_Semiring_new (&LAGraph_plus_first_uint8,
+     219             :         GrB_PLUS_MONOID_UINT8 , GrB_FIRST_UINT8 )) ;
+     220         167 :     GRB_TRY (GrB_Semiring_new (&LAGraph_plus_first_uint16,
+     221             :         GrB_PLUS_MONOID_UINT16, GrB_FIRST_UINT16)) ;
+     222         166 :     GRB_TRY (GrB_Semiring_new (&LAGraph_plus_first_uint32,
+     223             :         GrB_PLUS_MONOID_UINT32, GrB_FIRST_UINT32)) ;
+     224         165 :     GRB_TRY (GrB_Semiring_new (&LAGraph_plus_first_uint64,
+     225             :         GrB_PLUS_MONOID_UINT64, GrB_FIRST_UINT64)) ;
+     226         164 :     GRB_TRY (GrB_Semiring_new (&LAGraph_plus_first_fp32,
+     227             :         GrB_PLUS_MONOID_FP32  , GrB_FIRST_FP32  )) ;
+     228         163 :     GRB_TRY (GrB_Semiring_new (&LAGraph_plus_first_fp64,
+     229             :         GrB_PLUS_MONOID_FP64  , GrB_FIRST_FP64  )) ;
+     230             : 
+     231             :     // LAGraph_plus_second_T: using the GrB_PLUS_MONOID_T monoid and the
+     232             :     // GrB_SECOND_T multiplicative operator.  These semirings compute C=A*B
+     233             :     // where only the structure of A is accessed.  In MATLAB, this can be
+     234             :     // written as:
+     235             :     //
+     236             :     //      C = spones (A) * B
+     237             : 
+     238         162 :     GRB_TRY (GrB_Semiring_new (&LAGraph_plus_second_int8,
+     239             :         GrB_PLUS_MONOID_INT8  , GrB_SECOND_INT8  )) ;
+     240         161 :     GRB_TRY (GrB_Semiring_new (&LAGraph_plus_second_int16,
+     241             :         GrB_PLUS_MONOID_INT16 , GrB_SECOND_INT16 )) ;
+     242         160 :     GRB_TRY (GrB_Semiring_new (&LAGraph_plus_second_int32,
+     243             :         GrB_PLUS_MONOID_INT32 , GrB_SECOND_INT32 )) ;
+     244         159 :     GRB_TRY (GrB_Semiring_new (&LAGraph_plus_second_int64,
+     245             :         GrB_PLUS_MONOID_INT64 , GrB_SECOND_INT64 )) ;
+     246         158 :     GRB_TRY (GrB_Semiring_new (&LAGraph_plus_second_uint8,
+     247             :         GrB_PLUS_MONOID_UINT8 , GrB_SECOND_UINT8 )) ;
+     248         157 :     GRB_TRY (GrB_Semiring_new (&LAGraph_plus_second_uint16,
+     249             :         GrB_PLUS_MONOID_UINT16, GrB_SECOND_UINT16)) ;
+     250         156 :     GRB_TRY (GrB_Semiring_new (&LAGraph_plus_second_uint32,
+     251             :         GrB_PLUS_MONOID_UINT32, GrB_SECOND_UINT32)) ;
+     252         155 :     GRB_TRY (GrB_Semiring_new (&LAGraph_plus_second_uint64,
+     253             :         GrB_PLUS_MONOID_UINT64, GrB_SECOND_UINT64)) ;
+     254         154 :     GRB_TRY (GrB_Semiring_new (&LAGraph_plus_second_fp32,
+     255             :         GrB_PLUS_MONOID_FP32  , GrB_SECOND_FP32  )) ;
+     256         153 :     GRB_TRY (GrB_Semiring_new (&LAGraph_plus_second_fp64,
+     257             :         GrB_PLUS_MONOID_FP64  , GrB_SECOND_FP64  )) ;
+     258             : 
+     259             :     // LAGraph_plus_one_T: using the GrB_PLUS_MONOID_T monoid and the
+     260             :     // corresponding GrB_ONEB_T multiplicative operator.  These semirings
+     261             :     // compute a matrix C=A*B that does not depend on the type or values of
+     262             :     // the matrices A and B.  C(i,j) is the size of the intersection of the
+     263             :     // structures of A(i,:) and B(:,j).  In MATLAB, for the FP64 data type,
+     264             :     // this can be written as:
+     265             :     //
+     266             :     //      C = spones (A) * spones (B)
+     267             : 
+     268         152 :     GRB_TRY (GrB_Semiring_new (&LAGraph_plus_one_int8,
+     269             :         GrB_PLUS_MONOID_INT8  , GrB_ONEB_INT8  )) ;
+     270         151 :     GRB_TRY (GrB_Semiring_new (&LAGraph_plus_one_int16,
+     271             :         GrB_PLUS_MONOID_INT16 , GrB_ONEB_INT16 )) ;
+     272         150 :     GRB_TRY (GrB_Semiring_new (&LAGraph_plus_one_int32,
+     273             :         GrB_PLUS_MONOID_INT32 , GrB_ONEB_INT32 )) ;
+     274         149 :     GRB_TRY (GrB_Semiring_new (&LAGraph_plus_one_int64,
+     275             :         GrB_PLUS_MONOID_INT64 , GrB_ONEB_INT64 )) ;
+     276         148 :     GRB_TRY (GrB_Semiring_new (&LAGraph_plus_one_uint8,
+     277             :         GrB_PLUS_MONOID_UINT8 , GrB_ONEB_UINT8 )) ;
+     278         147 :     GRB_TRY (GrB_Semiring_new (&LAGraph_plus_one_uint16,
+     279             :         GrB_PLUS_MONOID_UINT16, GrB_ONEB_UINT16)) ;
+     280         146 :     GRB_TRY (GrB_Semiring_new (&LAGraph_plus_one_uint32,
+     281             :         GrB_PLUS_MONOID_UINT32, GrB_ONEB_UINT32)) ;
+     282         145 :     GRB_TRY (GrB_Semiring_new (&LAGraph_plus_one_uint64,
+     283             :         GrB_PLUS_MONOID_UINT64, GrB_ONEB_UINT64)) ;
+     284         144 :     GRB_TRY (GrB_Semiring_new (&LAGraph_plus_one_fp32,
+     285             :         GrB_PLUS_MONOID_FP32  , GrB_ONEB_FP32  )) ;
+     286         143 :     GRB_TRY (GrB_Semiring_new (&LAGraph_plus_one_fp64,
+     287             :         GrB_PLUS_MONOID_FP64  , GrB_ONEB_FP64  )) ;
+     288             : 
+     289             :     // LAGraph_any_one_T: using the GrB_MIN_MONOID_T for non-boolean types,
+     290             :     // or GrB_LOR_MONOID_BOOL for boolean, and the GrB_ONEB_T multiplicative
+     291             :     // operator.  Given any matrices A and B, C = A*B when using this semiring
+     292             :     // computes a matrix C whose values (for entries present) are all equal to
+     293             :     // 1.  The result is dependent only on the structure of A and B, not their
+     294             :     // data types or values.  In MATLAB, this could be written for FP64 as:
+     295             :     //
+     296             :     //      C = spones (spones (A) * spones (B))
+     297             :     //
+     298             :     // The MIN monoid could also be MAX, TIMES, or GxB_ANY (for SuiteSparse
+     299             :     // GraphBLAS), or it could be BOR or BAND for the unsigned integer types.
+     300             :     // The LOR monoid could also be LAND or EQ.  All of these monoids reduce
+     301             :     // a set of values { 1, 1, 1, ... 1, 1 } down to the single scalar value
+     302             :     // of 1, or true, and thus any of these monoids will compute the same
+     303             :     // thing.
+     304             : 
+     305         142 :     GRB_TRY (GrB_Semiring_new (&LAGraph_any_one_bool,
+     306             :         GrB_LOR_MONOID_BOOL   , GrB_ONEB_BOOL  )) ;
+     307         141 :     GRB_TRY (GrB_Semiring_new (&LAGraph_any_one_int8,
+     308             :         GrB_MIN_MONOID_INT8   , GrB_ONEB_INT8  )) ;
+     309         140 :     GRB_TRY (GrB_Semiring_new (&LAGraph_any_one_int16,
+     310             :         GrB_MIN_MONOID_INT16  , GrB_ONEB_INT16 )) ;
+     311         139 :     GRB_TRY (GrB_Semiring_new (&LAGraph_any_one_int32,
+     312             :         GrB_MIN_MONOID_INT32  , GrB_ONEB_INT32 )) ;
+     313         138 :     GRB_TRY (GrB_Semiring_new (&LAGraph_any_one_int64,
+     314             :         GrB_MIN_MONOID_INT64  , GrB_ONEB_INT64 )) ;
+     315         137 :     GRB_TRY (GrB_Semiring_new (&LAGraph_any_one_uint8,
+     316             :         GrB_MIN_MONOID_UINT8  , GrB_ONEB_UINT8 )) ;
+     317         136 :     GRB_TRY (GrB_Semiring_new (&LAGraph_any_one_uint16,
+     318             :         GrB_MIN_MONOID_UINT16 , GrB_ONEB_UINT16)) ;
+     319         135 :     GRB_TRY (GrB_Semiring_new (&LAGraph_any_one_uint32,
+     320             :         GrB_MIN_MONOID_UINT32 , GrB_ONEB_UINT32)) ;
+     321         134 :     GRB_TRY (GrB_Semiring_new (&LAGraph_any_one_uint64,
+     322             :         GrB_MIN_MONOID_UINT64 , GrB_ONEB_UINT64)) ;
+     323         133 :     GRB_TRY (GrB_Semiring_new (&LAGraph_any_one_fp32,
+     324             :         GrB_MIN_MONOID_FP32   , GrB_ONEB_FP32  )) ;
+     325         132 :     GRB_TRY (GrB_Semiring_new (&LAGraph_any_one_fp64,
+     326             :         GrB_MIN_MONOID_FP64   , GrB_ONEB_FP64  )) ;
+     327             : 
+     328         131 :     LG_set_LAGr_Init_has_been_called (true) ;
+     329         131 :     return (GrB_SUCCESS) ;
+     330             : }
+     331             : 
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGr_SampleDegree.c.func-sort-c.html b/src/utility/LAGr_SampleDegree.c.func-sort-c.html new file mode 100644 index 0000000000..14f87843f2 --- /dev/null +++ b/src/utility/LAGr_SampleDegree.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGr_SampleDegree.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGr_SampleDegree.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:2727100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGr_SampleDegree228
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGr_SampleDegree.c.func.html b/src/utility/LAGr_SampleDegree.c.func.html new file mode 100644 index 0000000000..326f0280f1 --- /dev/null +++ b/src/utility/LAGr_SampleDegree.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGr_SampleDegree.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGr_SampleDegree.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:2727100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGr_SampleDegree228
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGr_SampleDegree.c.gcov.html b/src/utility/LAGr_SampleDegree.c.gcov.html new file mode 100644 index 0000000000..90f96ba40a --- /dev/null +++ b/src/utility/LAGr_SampleDegree.c.gcov.html @@ -0,0 +1,188 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGr_SampleDegree.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGr_SampleDegree.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:2727100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGr_SampleDegree: sample the degree median and mean
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // LAGr_SampleDegree computes estimates of the mean and median of the
+      19             : // row or column degree of a graph.
+      20             : 
+      21             : #define LG_FREE_ALL LAGraph_Free ((void **) &samples, NULL) ;
+      22             : 
+      23             : #include "LG_internal.h"
+      24             : 
+      25         228 : int LAGr_SampleDegree
+      26             : (
+      27             :     // output:
+      28             :     double *sample_mean,    // sampled mean degree
+      29             :     double *sample_median,  // sampled median degree
+      30             :     // input:
+      31             :     const LAGraph_Graph G,  // graph of n nodes
+      32             :     bool byout,             // if true, sample G->out_degree, else G->in_degree
+      33             :     int64_t nsamples,       // number of samples
+      34             :     uint64_t seed,          // random number seed
+      35             :     char *msg
+      36             : )
+      37             : {
+      38             : 
+      39             :     //--------------------------------------------------------------------------
+      40             :     // check inputs
+      41             :     //--------------------------------------------------------------------------
+      42             : 
+      43         228 :     LG_CLEAR_MSG ;
+      44         228 :     int64_t *samples = NULL ;
+      45         228 :     LG_ASSERT (sample_mean != NULL, GrB_NULL_POINTER) ;
+      46         228 :     LG_ASSERT (sample_median != NULL, GrB_NULL_POINTER) ;
+      47         228 :     nsamples = LAGRAPH_MAX (nsamples, 1) ;
+      48         228 :     LG_TRY (LAGraph_CheckGraph (G, msg)) ;
+      49             : 
+      50             :     GrB_Vector Degree ;
+      51             : 
+      52         228 :     if (G->kind == LAGraph_ADJACENCY_UNDIRECTED ||
+      53         202 :        (G->kind == LAGraph_ADJACENCY_DIRECTED &&
+      54         202 :         G->is_symmetric_structure == LAGraph_TRUE))
+      55             :     {
+      56             :         // the structure of A is known to be symmetric
+      57         156 :         Degree = G->out_degree ;
+      58             :     }
+      59             :     else
+      60             :     {
+      61             :         // A is not known to be symmetric
+      62          72 :         Degree = (byout) ? G->out_degree : G->in_degree ;
+      63             :     }
+      64             : 
+      65         228 :     LG_ASSERT_MSG (Degree != NULL, LAGRAPH_NOT_CACHED, "degree unknown") ;
+      66             : 
+      67             :     //--------------------------------------------------------------------------
+      68             :     // allocate workspace
+      69             :     //--------------------------------------------------------------------------
+      70             : 
+      71         210 :     LG_TRY (LAGraph_Malloc ((void **) &samples, nsamples, sizeof (int64_t),
+      72             :         msg)) ;
+      73             : 
+      74             :     //--------------------------------------------------------------------------
+      75             :     // pick nsamples nodes at random and determine their degree
+      76             :     //--------------------------------------------------------------------------
+      77             : 
+      78             :     // See also the hashed sampling method in LG_CC_FastSV6, which computes a
+      79             :     // fast estimate of the mode of an integer vector.  This method does not
+      80             :     // require a hash table.  However, the mode estimator in LG_CC_FastSV6
+      81             :     // would be a good candidate to add as an LAGraph_SampleMode utility
+      82             :     // function.
+      83             : 
+      84             :     GrB_Index n ;
+      85         186 :     GRB_TRY (GrB_Vector_size (&n, Degree)) ;
+      86             : 
+      87         186 :     int64_t dsum = 0 ;
+      88      150406 :     for (int k = 0 ; k < nsamples ; k++)
+      89             :     {
+      90      150220 :         uint64_t result = LG_Random60 (&seed) ;
+      91      150220 :         int64_t i = result % n ;
+      92             :         // d = Degree (i)
+      93             :         int64_t d ;
+      94      150220 :         GRB_TRY (GrB_Vector_extractElement (&d, Degree, i)) ;
+      95      150220 :         samples [k] = d ;
+      96      150220 :         dsum += d ;
+      97             :     }
+      98             : 
+      99             :     // find the mean degree
+     100         186 :     (*sample_mean) = ((double) dsum) / nsamples ;
+     101             : 
+     102             :     // find the median degree
+     103         186 :     LG_qsort_1a (samples, nsamples) ;
+     104         186 :     (*sample_median) = (double) samples [nsamples/2] ;
+     105             : 
+     106             :     //--------------------------------------------------------------------------
+     107             :     // free workspace and return result
+     108             :     //--------------------------------------------------------------------------
+     109             : 
+     110         186 :     LG_FREE_ALL ;
+     111         186 :     return (GrB_SUCCESS) ;
+     112             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGr_SortByDegree.c.func-sort-c.html b/src/utility/LAGr_SortByDegree.c.func-sort-c.html new file mode 100644 index 0000000000..bb3d32616f --- /dev/null +++ b/src/utility/LAGr_SortByDegree.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGr_SortByDegree.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGr_SortByDegree.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3838100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGr_SortByDegree1538
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGr_SortByDegree.c.func.html b/src/utility/LAGr_SortByDegree.c.func.html new file mode 100644 index 0000000000..ef8086f93d --- /dev/null +++ b/src/utility/LAGr_SortByDegree.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGr_SortByDegree.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGr_SortByDegree.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3838100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGr_SortByDegree1538
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGr_SortByDegree.c.gcov.html b/src/utility/LAGr_SortByDegree.c.gcov.html new file mode 100644 index 0000000000..15d358bdec --- /dev/null +++ b/src/utility/LAGr_SortByDegree.c.gcov.html @@ -0,0 +1,243 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGr_SortByDegree.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGr_SortByDegree.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3838100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGr_SortByDegree: sort a graph by its row or column degree
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // LAGr_SortByDegree computes a permutation vector P that sorts a graph
+      19             : // by degree (either row or column degree of its adjacency matrix A).
+      20             : // If G is undirected, or if G is directed but is known to have a symmetric
+      21             : // adjacency matrix, then G->out_degree is used (and byout is ignored).
+      22             : // Otherwise, if G->out_degree is used if byout is true, and G->in_degree is
+      23             : // used if byout is false.
+      24             : 
+      25             : // G->out_degree or G->in_degree must first be computed.  An error is returned
+      26             : // if the required degree vector has not yet been computed.  See
+      27             : // LAGraph_Cached_OutDegree and LAGraph_Cached_InDegree.
+      28             : 
+      29             : // The permutation is in ascending order of degree if ascending is true, and
+      30             : // in descending order otherwise.
+      31             : 
+      32             : // Ties are broken by the node id, so the sort is always predicable.  Lower
+      33             : // numbered rows/columns always appear before higher ones, if they have the
+      34             : // same degree.
+      35             : 
+      36             : // The output is a permutation P where P [k] = i if row i is the kth row in
+      37             : // the permutation (or P [k] = j if column j is the kth column in the
+      38             : // permutation, with byout false).
+      39             : 
+      40             : #define LG_FREE_WORK                    \
+      41             : {                                       \
+      42             :     LAGraph_Free ((void **) &W, NULL) ; \
+      43             :     LAGraph_Free ((void **) &D, NULL) ; \
+      44             : }
+      45             : 
+      46             : #define LG_FREE_ALL                     \
+      47             : {                                       \
+      48             :     LG_FREE_WORK ;                      \
+      49             :     LAGraph_Free ((void **) &P, NULL) ; \
+      50             : }
+      51             : 
+      52             : #include "LG_internal.h"
+      53             : 
+      54        1538 : int LAGr_SortByDegree
+      55             : (
+      56             :     // output:
+      57             :     int64_t **P_handle,     // permutation vector of size n
+      58             :     // input:
+      59             :     const LAGraph_Graph G,  // graph of n nodes
+      60             :     bool byout,             // if true, sort G->out_degree, else G->in_degree
+      61             :     bool ascending,         // sort in ascending or descending order
+      62             :     char *msg
+      63             : )
+      64             : {
+      65             : 
+      66             :     //--------------------------------------------------------------------------
+      67             :     // check inputs
+      68             :     //--------------------------------------------------------------------------
+      69             : 
+      70        1538 :     LG_CLEAR_MSG ;
+      71        1538 :     int64_t *P = NULL ;
+      72        1538 :     int64_t *W = NULL ;
+      73        1538 :     int64_t *D = NULL ;
+      74        1538 :     LG_ASSERT_MSG (P_handle != NULL, GrB_NULL_POINTER, "&P != NULL") ;
+      75        1537 :     (*P_handle) = NULL ;
+      76        1537 :     LG_TRY (LAGraph_CheckGraph (G, msg)) ;
+      77             : 
+      78             :     GrB_Vector Degree ;
+      79             : 
+      80        1536 :     if (G->kind == LAGraph_ADJACENCY_UNDIRECTED ||
+      81        1441 :        (G->kind == LAGraph_ADJACENCY_DIRECTED &&
+      82        1441 :         G->is_symmetric_structure == LAGraph_TRUE))
+      83             :     {
+      84             :         // the structure of A is known to be symmetric
+      85        1440 :         Degree = G->out_degree ;
+      86             :     }
+      87             :     else
+      88             :     {
+      89             :         // A is not known to be symmetric
+      90          96 :         Degree = (byout) ? G->out_degree : G->in_degree ;
+      91             :     }
+      92             : 
+      93        1536 :     LG_ASSERT_MSG (Degree != NULL, LAGRAPH_NOT_CACHED, "degree unknown") ;
+      94             : 
+      95             :     //--------------------------------------------------------------------------
+      96             :     // decide how many threads to use
+      97             :     //--------------------------------------------------------------------------
+      98             : 
+      99             :     GrB_Index n ;
+     100        1535 :     GRB_TRY (GrB_Vector_size (&n, Degree)) ;
+     101             : 
+     102             :     #define CHUNK (64*1024)
+     103        1535 :     int nthreads = LG_nthreads_outer * LG_nthreads_inner ;
+     104        1535 :     nthreads = LAGRAPH_MIN (nthreads, n/CHUNK) ;
+     105        1535 :     nthreads = LAGRAPH_MAX (nthreads, 1) ;
+     106             : 
+     107             :     //--------------------------------------------------------------------------
+     108             :     // allocate result and workspace
+     109             :     //--------------------------------------------------------------------------
+     110             : 
+     111        1535 :     LG_TRY (LAGraph_Malloc ((void **) &P, n, sizeof (int64_t), msg)) ;
+     112        1490 :     LG_TRY (LAGraph_Malloc ((void **) &D, n, sizeof (int64_t), msg)) ;
+     113        1445 :     LG_TRY (LAGraph_Malloc ((void **) &W, 2*n, sizeof (int64_t), msg)) ;
+     114        1400 :     int64_t *W0 = W ;
+     115        1400 :     int64_t *W1 = W + n ;
+     116             : 
+     117             :     //--------------------------------------------------------------------------
+     118             :     // construct the pair [D,P] to sort
+     119             :     //--------------------------------------------------------------------------
+     120             : 
+     121             :     int64_t k;
+     122             :     #pragma omp parallel for num_threads(nthreads) schedule(static)
+     123      808490 :     for (k = 0 ; k < n ; k++)
+     124             :     {
+     125      807090 :         D [k] = 0 ;
+     126      807090 :         P [k] = k ;
+     127             :     }
+     128             : 
+     129             :     // extract the degrees
+     130        1400 :     GrB_Index nvals = n ;
+     131        1400 :     GRB_TRY (GrB_Vector_extractTuples ((GrB_Index *) W0, W1, &nvals, Degree)) ;
+     132             : 
+     133        1400 :     if (ascending)
+     134             :     {
+     135             :         // sort [D,P] in ascending order of degree, tie-breaking on P
+     136             :         #pragma omp parallel for num_threads(nthreads) schedule(static)
+     137      706700 :         for (k = 0 ; k < nvals ; k++)
+     138             :         {
+     139      705446 :             D [W0 [k]] = W1 [k] ;
+     140             :         }
+     141             :     }
+     142             :     else
+     143             :     {
+     144             :         // sort [D,P] in descending order of degree, tie-breaking on P
+     145             :         #pragma omp parallel for num_threads(nthreads) schedule(static)
+     146      101686 :         for (k = 0 ; k < nvals ; k++)
+     147             :         {
+     148      101540 :             D [W0 [k]] = -W1 [k] ;
+     149             :         }
+     150             :     }
+     151             : 
+     152        1400 :     LG_TRY (LAGraph_Free ((void **) &W, NULL)) ;
+     153             : 
+     154             :     //--------------------------------------------------------------------------
+     155             :     // sort by degrees, with ties by node id
+     156             :     //--------------------------------------------------------------------------
+     157             : 
+     158        1400 :     LG_TRY (LG_msort2 (D, P, n, msg)) ;
+     159             : 
+     160             :     //--------------------------------------------------------------------------
+     161             :     // free workspace and return result
+     162             :     //--------------------------------------------------------------------------
+     163             : 
+     164        1400 :     LG_FREE_WORK ;
+     165        1400 :     (*P_handle) = P ;
+     166        1400 :     return (GrB_SUCCESS) ;
+     167             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Cached_AT.c.func-sort-c.html b/src/utility/LAGraph_Cached_AT.c.func-sort-c.html new file mode 100644 index 0000000000..60a2d6e691 --- /dev/null +++ b/src/utility/LAGraph_Cached_AT.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Cached_AT.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Cached_AT.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1616100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_Cached_AT1279
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Cached_AT.c.func.html b/src/utility/LAGraph_Cached_AT.c.func.html new file mode 100644 index 0000000000..3e880ef3b2 --- /dev/null +++ b/src/utility/LAGraph_Cached_AT.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Cached_AT.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Cached_AT.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1616100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_Cached_AT1279
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Cached_AT.c.gcov.html b/src/utility/LAGraph_Cached_AT.c.gcov.html new file mode 100644 index 0000000000..fbdab3c75d --- /dev/null +++ b/src/utility/LAGraph_Cached_AT.c.gcov.html @@ -0,0 +1,142 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Cached_AT.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Cached_AT.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1616100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_Cached_AT: construct G->AT for a graph
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #define LG_FREE_ALL GrB_free (&AT) ;
+      19             : 
+      20             : #include "LG_internal.h"
+      21             : 
+      22        1279 : int LAGraph_Cached_AT
+      23             : (
+      24             :     // input/output:
+      25             :     LAGraph_Graph G,    // graph for which to compute G->AT
+      26             :     char *msg
+      27             : )
+      28             : {
+      29             : 
+      30             :     //--------------------------------------------------------------------------
+      31             :     // clear msg and check G
+      32             :     //--------------------------------------------------------------------------
+      33             : 
+      34        1279 :     GrB_Matrix AT = NULL ;
+      35        1279 :     LG_CLEAR_MSG_AND_BASIC_ASSERT (G, msg) ;
+      36        1279 :     GrB_Matrix A = G->A ;
+      37             : 
+      38        1279 :     if (G->AT != NULL)
+      39             :     {
+      40             :         // G->AT already computed
+      41          42 :         return (GrB_SUCCESS) ;
+      42             :     }
+      43             : 
+      44        1237 :     if (G->kind == LAGraph_ADJACENCY_UNDIRECTED)
+      45             :     {
+      46             :         // G->AT not needed since A is symmetric (warning only, not an error)
+      47          72 :         return (LAGRAPH_CACHE_NOT_NEEDED) ;
+      48             :     }
+      49             : 
+      50             :     //--------------------------------------------------------------------------
+      51             :     // G->AT = (G->A)'
+      52             :     //--------------------------------------------------------------------------
+      53             : 
+      54             :     GrB_Index nrows, ncols ;
+      55        1165 :     GRB_TRY (GrB_Matrix_nrows (&nrows, A)) ;
+      56        1165 :     GRB_TRY (GrB_Matrix_ncols (&ncols, A)) ;
+      57             :     GrB_Type atype ;
+      58             :     char atype_name [LAGRAPH_MAX_NAME_LEN] ;
+      59        1165 :     LG_TRY (LAGraph_Matrix_TypeName (atype_name, A, msg)) ;
+      60        1165 :     LG_TRY (LAGraph_TypeFromName (&atype, atype_name, msg)) ;
+      61        1165 :     GRB_TRY (GrB_Matrix_new (&AT, atype, ncols, nrows)) ;
+      62         848 :     GRB_TRY (GrB_transpose (AT, NULL, NULL, A, NULL)) ;
+      63         605 :     G->AT = AT ;
+      64             : 
+      65         605 :     return (GrB_SUCCESS) ;
+      66             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Cached_EMax.c.func-sort-c.html b/src/utility/LAGraph_Cached_EMax.c.func-sort-c.html new file mode 100644 index 0000000000..55e1b152c2 --- /dev/null +++ b/src/utility/LAGraph_Cached_EMax.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Cached_EMax.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Cached_EMax.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:2323100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_Cached_EMax67
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Cached_EMax.c.func.html b/src/utility/LAGraph_Cached_EMax.c.func.html new file mode 100644 index 0000000000..182263c757 --- /dev/null +++ b/src/utility/LAGraph_Cached_EMax.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Cached_EMax.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Cached_EMax.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:2323100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_Cached_EMax67
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Cached_EMax.c.gcov.html b/src/utility/LAGraph_Cached_EMax.c.gcov.html new file mode 100644 index 0000000000..3925b6bf58 --- /dev/null +++ b/src/utility/LAGraph_Cached_EMax.c.gcov.html @@ -0,0 +1,156 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Cached_EMax.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Cached_EMax.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:2323100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_Cached_EMax: determine G->emax
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #define LG_FREE_ALL             \
+      19             : {                               \
+      20             :     GrB_free (&G->emax) ;       \
+      21             : }
+      22             : 
+      23             : #include "LG_internal.h"
+      24             : 
+      25          67 : int LAGraph_Cached_EMax
+      26             : (
+      27             :     // input/output:
+      28             :     LAGraph_Graph G,    // graph to determine G->emax
+      29             :     char *msg
+      30             : )
+      31             : {
+      32             : 
+      33             :     //--------------------------------------------------------------------------
+      34             :     // clear msg and check G
+      35             :     //--------------------------------------------------------------------------
+      36             : 
+      37          67 :     LG_CLEAR_MSG_AND_BASIC_ASSERT (G, msg) ;
+      38             : 
+      39          67 :     if (G->emax != NULL)
+      40             :     {
+      41             :         // G->emax already computed
+      42           2 :         return (GrB_SUCCESS) ;
+      43             :     }
+      44             : 
+      45          65 :     G->emax_state = LAGRAPH_UNKNOWN ;
+      46             : 
+      47             :     //--------------------------------------------------------------------------
+      48             :     // determine the type of G->A and the corresponding max monoid
+      49             :     //--------------------------------------------------------------------------
+      50             : 
+      51             :     char atype_name [LAGRAPH_MAX_NAME_LEN] ;
+      52          65 :     LG_TRY (LAGraph_Matrix_TypeName (atype_name, G->A, msg)) ;
+      53             :     GrB_Type atype ;
+      54          65 :     LG_TRY (LAGraph_TypeFromName (&atype, atype_name, msg)) ;
+      55             :     GrB_Monoid monoid ;
+      56          65 :     if      (atype == GrB_BOOL  ) monoid = GrB_LOR_MONOID_BOOL  ;
+      57          48 :     else if (atype == GrB_INT8  ) monoid = GrB_MAX_MONOID_INT8   ;
+      58          46 :     else if (atype == GrB_INT16 ) monoid = GrB_MAX_MONOID_INT16  ;
+      59          44 :     else if (atype == GrB_INT32 ) monoid = GrB_MAX_MONOID_INT32  ;
+      60          38 :     else if (atype == GrB_INT64 ) monoid = GrB_MAX_MONOID_INT64  ;
+      61          30 :     else if (atype == GrB_UINT8 ) monoid = GrB_MAX_MONOID_UINT8  ;
+      62          29 :     else if (atype == GrB_UINT16) monoid = GrB_MAX_MONOID_UINT16 ;
+      63          28 :     else if (atype == GrB_UINT32) monoid = GrB_MAX_MONOID_UINT32 ;
+      64          27 :     else if (atype == GrB_UINT64) monoid = GrB_MAX_MONOID_UINT64 ;
+      65          26 :     else if (atype == GrB_FP32  ) monoid = GrB_MAX_MONOID_FP32   ;
+      66          24 :     else if (atype == GrB_FP64  ) monoid = GrB_MAX_MONOID_FP64   ;
+      67             :     else
+      68             :     {
+      69           1 :         LG_ASSERT_MSG (false, GrB_NOT_IMPLEMENTED, "type not supported") ;
+      70             :     }
+      71             : 
+      72             :     //--------------------------------------------------------------------------
+      73             :     // compute G->emax
+      74             :     //--------------------------------------------------------------------------
+      75             : 
+      76          64 :     GRB_TRY (GrB_Scalar_new (&(G->emax), atype)) ;
+      77          64 :     GRB_TRY (GrB_reduce (G->emax, NULL, monoid, G->A, NULL)) ;
+      78          64 :     G->emax_state = LAGraph_VALUE ;
+      79          64 :     return (GrB_SUCCESS) ;
+      80             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Cached_EMin.c.func-sort-c.html b/src/utility/LAGraph_Cached_EMin.c.func-sort-c.html new file mode 100644 index 0000000000..ff307d467f --- /dev/null +++ b/src/utility/LAGraph_Cached_EMin.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Cached_EMin.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Cached_EMin.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:2323100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_Cached_EMin96
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Cached_EMin.c.func.html b/src/utility/LAGraph_Cached_EMin.c.func.html new file mode 100644 index 0000000000..d0665de15a --- /dev/null +++ b/src/utility/LAGraph_Cached_EMin.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Cached_EMin.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Cached_EMin.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:2323100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_Cached_EMin96
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Cached_EMin.c.gcov.html b/src/utility/LAGraph_Cached_EMin.c.gcov.html new file mode 100644 index 0000000000..21843ea2ec --- /dev/null +++ b/src/utility/LAGraph_Cached_EMin.c.gcov.html @@ -0,0 +1,156 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Cached_EMin.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Cached_EMin.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:2323100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_Cached_EMin: determine G->emin
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #define LG_FREE_ALL             \
+      19             : {                               \
+      20             :     GrB_free (&G->emin) ;       \
+      21             : }
+      22             : 
+      23             : #include "LG_internal.h"
+      24             : 
+      25          96 : int LAGraph_Cached_EMin
+      26             : (
+      27             :     // input/output:
+      28             :     LAGraph_Graph G,    // graph to determine G->emin
+      29             :     char *msg
+      30             : )
+      31             : {
+      32             : 
+      33             :     //--------------------------------------------------------------------------
+      34             :     // clear msg and check G
+      35             :     //--------------------------------------------------------------------------
+      36             : 
+      37          96 :     LG_CLEAR_MSG_AND_BASIC_ASSERT (G, msg) ;
+      38             : 
+      39          96 :     if (G->emin != NULL)
+      40             :     {
+      41             :         // G->emin already computed
+      42           2 :         return (GrB_SUCCESS) ;
+      43             :     }
+      44             : 
+      45          94 :     G->emin_state = LAGRAPH_UNKNOWN ;
+      46             : 
+      47             :     //--------------------------------------------------------------------------
+      48             :     // determine the type of G->A and the corresponding min monoid
+      49             :     //--------------------------------------------------------------------------
+      50             : 
+      51             :     char atype_name [LAGRAPH_MAX_NAME_LEN] ;
+      52          94 :     LG_TRY (LAGraph_Matrix_TypeName (atype_name, G->A, msg)) ;
+      53             :     GrB_Type atype ;
+      54          94 :     LG_TRY (LAGraph_TypeFromName (&atype, atype_name, msg)) ;
+      55             :     GrB_Monoid monoid ;
+      56          94 :     if      (atype == GrB_BOOL  ) monoid = GrB_LAND_MONOID_BOOL  ;
+      57          77 :     else if (atype == GrB_INT8  ) monoid = GrB_MIN_MONOID_INT8   ;
+      58          75 :     else if (atype == GrB_INT16 ) monoid = GrB_MIN_MONOID_INT16  ;
+      59          73 :     else if (atype == GrB_INT32 ) monoid = GrB_MIN_MONOID_INT32  ;
+      60          66 :     else if (atype == GrB_INT64 ) monoid = GrB_MIN_MONOID_INT64  ;
+      61          53 :     else if (atype == GrB_UINT8 ) monoid = GrB_MIN_MONOID_UINT8  ;
+      62          52 :     else if (atype == GrB_UINT16) monoid = GrB_MIN_MONOID_UINT16 ;
+      63          51 :     else if (atype == GrB_UINT32) monoid = GrB_MIN_MONOID_UINT32 ;
+      64          49 :     else if (atype == GrB_UINT64) monoid = GrB_MIN_MONOID_UINT64 ;
+      65          47 :     else if (atype == GrB_FP32  ) monoid = GrB_MIN_MONOID_FP32   ;
+      66          44 :     else if (atype == GrB_FP64  ) monoid = GrB_MIN_MONOID_FP64   ;
+      67             :     else
+      68             :     {
+      69           1 :         LG_ASSERT_MSG (false, GrB_NOT_IMPLEMENTED, "type not supported") ;
+      70             :     }
+      71             : 
+      72             :     //--------------------------------------------------------------------------
+      73             :     // compute G->emin
+      74             :     //--------------------------------------------------------------------------
+      75             : 
+      76          93 :     GRB_TRY (GrB_Scalar_new (&(G->emin), atype)) ;
+      77          93 :     GRB_TRY (GrB_reduce (G->emin, NULL, monoid, G->A, NULL)) ;
+      78          93 :     G->emin_state = LAGraph_VALUE ;
+      79          93 :     return (GrB_SUCCESS) ;
+      80             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Cached_InDegree.c.func-sort-c.html b/src/utility/LAGraph_Cached_InDegree.c.func-sort-c.html new file mode 100644 index 0000000000..42f2d452c8 --- /dev/null +++ b/src/utility/LAGraph_Cached_InDegree.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Cached_InDegree.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Cached_InDegree.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:2121100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_Cached_InDegree1419
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Cached_InDegree.c.func.html b/src/utility/LAGraph_Cached_InDegree.c.func.html new file mode 100644 index 0000000000..659f8bb275 --- /dev/null +++ b/src/utility/LAGraph_Cached_InDegree.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Cached_InDegree.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Cached_InDegree.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:2121100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_Cached_InDegree1419
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Cached_InDegree.c.gcov.html b/src/utility/LAGraph_Cached_InDegree.c.gcov.html new file mode 100644 index 0000000000..50f54a845f --- /dev/null +++ b/src/utility/LAGraph_Cached_InDegree.c.gcov.html @@ -0,0 +1,181 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Cached_InDegree.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Cached_InDegree.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:2121100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_Cached_InDegree: determine G->in_degree
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // LAGraph_Cached_InDegree computes G->in_degree, where G->in_degree(j) is
+      19             : // the number of entries in G->A (:,j).  If there are no entries in G->A (:,j),
+      20             : // G->coldgree(j) is not present in the structure of G->in_degree.  That is,
+      21             : // G->in_degree contains no explicit zero entries.
+      22             : 
+      23             : // G->in_degree is not computed if the graph is undirected.  Use G->out_degree
+      24             : // instead, and LAGraph_Cached_OutDegree.
+      25             : 
+      26             : #define LG_FREE_WORK            \
+      27             : {                               \
+      28             :     GrB_free (&S) ;             \
+      29             :     GrB_free (&x) ;             \
+      30             : }
+      31             : 
+      32             : #define LG_FREE_ALL             \
+      33             : {                               \
+      34             :     LG_FREE_WORK ;              \
+      35             :     GrB_free (&in_degree) ;    \
+      36             : }
+      37             : 
+      38             : #include "LG_internal.h"
+      39             : 
+      40        1419 : int LAGraph_Cached_InDegree
+      41             : (
+      42             :     // input/output:
+      43             :     LAGraph_Graph G,    // graph to determine G->in_degree
+      44             :     char *msg
+      45             : )
+      46             : {
+      47             : 
+      48             :     //--------------------------------------------------------------------------
+      49             :     // clear msg and check G
+      50             :     //--------------------------------------------------------------------------
+      51             : 
+      52        1419 :     GrB_Matrix S = NULL ;
+      53        1419 :     GrB_Vector in_degree = NULL, x = NULL ;
+      54        1419 :     LG_CLEAR_MSG_AND_BASIC_ASSERT (G, msg) ;
+      55             : 
+      56        1418 :     if (G->in_degree != NULL)
+      57             :     {
+      58             :         // G->in_degree already computed
+      59         110 :         return (GrB_SUCCESS) ;
+      60             :     }
+      61             : 
+      62        1308 :     if (G->kind == LAGraph_ADJACENCY_UNDIRECTED)
+      63             :     {
+      64             :         // G->in_degree is not computed since A is symmetric (warning only)
+      65         152 :         return (LAGRAPH_CACHE_NOT_NEEDED) ;
+      66             :     }
+      67             : 
+      68             :     //--------------------------------------------------------------------------
+      69             :     // determine the size of A
+      70             :     //--------------------------------------------------------------------------
+      71             : 
+      72        1156 :     GrB_Matrix A = G->A ;
+      73        1156 :     GrB_Matrix AT = G->AT ;
+      74             :     GrB_Index nrows, ncols ;
+      75        1156 :     GRB_TRY (GrB_Matrix_nrows (&nrows, A)) ;
+      76        1156 :     GRB_TRY (GrB_Matrix_ncols (&ncols, A)) ;
+      77             : 
+      78             :     //--------------------------------------------------------------------------
+      79             :     // compute the in_degree
+      80             :     //--------------------------------------------------------------------------
+      81             : 
+      82        1156 :     GRB_TRY (GrB_Vector_new (&in_degree, GrB_INT64, ncols)) ;
+      83             :     // x = zeros (nrows,1)
+      84         962 :     GRB_TRY (GrB_Vector_new (&x, GrB_INT64, nrows)) ;
+      85         768 :     GRB_TRY (GrB_assign (x, NULL, NULL, 0, GrB_ALL, nrows, NULL)) ;
+      86             : 
+      87         671 :     if (AT != NULL)
+      88             :     {
+      89             :         // G->in_degree = row degree of AT; this will be faster assuming
+      90             :         // AT is held in a row-oriented format.
+      91         243 :         GRB_TRY (GrB_mxv (in_degree, NULL, NULL, LAGraph_plus_one_int64,
+      92             :             AT, x, NULL)) ;
+      93             :     }
+      94             :     else
+      95             :     {
+      96             :         // G->in_degree = column degree of A
+      97         428 :         GRB_TRY (GrB_mxv (in_degree, NULL, NULL, LAGraph_plus_one_int64,
+      98             :             A, x, GrB_DESC_T0)) ;
+      99             :     }
+     100             : 
+     101         470 :     G->in_degree = in_degree ;
+     102             : 
+     103         470 :     LG_FREE_WORK ;
+     104         470 :     return (GrB_SUCCESS) ;
+     105             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Cached_IsSymmetricStructure.c.func-sort-c.html b/src/utility/LAGraph_Cached_IsSymmetricStructure.c.func-sort-c.html new file mode 100644 index 0000000000..833c946ded --- /dev/null +++ b/src/utility/LAGraph_Cached_IsSymmetricStructure.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Cached_IsSymmetricStructure.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Cached_IsSymmetricStructure.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:2424100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_Cached_IsSymmetricStructure1658
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Cached_IsSymmetricStructure.c.func.html b/src/utility/LAGraph_Cached_IsSymmetricStructure.c.func.html new file mode 100644 index 0000000000..cb7eff5780 --- /dev/null +++ b/src/utility/LAGraph_Cached_IsSymmetricStructure.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Cached_IsSymmetricStructure.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Cached_IsSymmetricStructure.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:2424100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_Cached_IsSymmetricStructure1658
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Cached_IsSymmetricStructure.c.gcov.html b/src/utility/LAGraph_Cached_IsSymmetricStructure.c.gcov.html new file mode 100644 index 0000000000..c1aafe6a69 --- /dev/null +++ b/src/utility/LAGraph_Cached_IsSymmetricStructure.c.gcov.html @@ -0,0 +1,179 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Cached_IsSymmetricStructure.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Cached_IsSymmetricStructure.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:2424100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_Cached_IsSymmetricStructure: determine G->is_symmetric_structure
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // Also computes G->AT if not already computed, if G is not an undirected
+      19             : // graph and G->A is square.
+      20             : 
+      21             : #define LG_FREE_WORK        \
+      22             : {                           \
+      23             :     GrB_free (&S1) ;        \
+      24             :     GrB_free (&S2) ;        \
+      25             :     GrB_free (&C) ;         \
+      26             : }
+      27             : 
+      28             : #include "LG_internal.h"
+      29             : 
+      30        1658 : int LAGraph_Cached_IsSymmetricStructure
+      31             : (
+      32             :     // input/output:
+      33             :     LAGraph_Graph G,    // graph to determine the symmetry of structure of A
+      34             :     char *msg
+      35             : )
+      36             : {
+      37             : 
+      38             :     //--------------------------------------------------------------------------
+      39             :     // clear msg and check G
+      40             :     //--------------------------------------------------------------------------
+      41             : 
+      42        1658 :     GrB_Matrix C = NULL, S1 = NULL, S2 = NULL ;
+      43        1658 :     LG_CLEAR_MSG_AND_BASIC_ASSERT (G, msg) ;
+      44             : 
+      45        1657 :     if (G->kind == LAGraph_ADJACENCY_UNDIRECTED)
+      46             :     {
+      47             :         // assume A is symmetric for an undirected graph
+      48         349 :         G->is_symmetric_structure = LAGraph_TRUE ;
+      49         349 :         return (GrB_SUCCESS) ;
+      50             :     }
+      51             : 
+      52        1308 :     if (G->is_symmetric_structure != LAGRAPH_UNKNOWN)
+      53             :     {
+      54             :         // cached symmetric property is already known
+      55         207 :         return (GrB_SUCCESS) ;
+      56             :     }
+      57             : 
+      58             :     //--------------------------------------------------------------------------
+      59             :     // determine the size of A
+      60             :     //--------------------------------------------------------------------------
+      61             : 
+      62        1101 :     GrB_Matrix A = G->A ;
+      63             :     GrB_Index n, ncols ;
+      64        1101 :     GRB_TRY (GrB_Matrix_nrows (&n, A)) ;
+      65        1101 :     GRB_TRY (GrB_Matrix_ncols (&ncols, A)) ;
+      66        1101 :     if (n != ncols)
+      67             :     {
+      68             :         // A is rectangular and thus cannot be symmetric
+      69          16 :         G->is_symmetric_structure = LAGraph_FALSE ;
+      70          16 :         return (GrB_SUCCESS) ;
+      71             :     }
+      72             : 
+      73             :     //--------------------------------------------------------------------------
+      74             :     // compute the transpose, if not already computed
+      75             :     //--------------------------------------------------------------------------
+      76             : 
+      77        1085 :     if (G->AT == NULL)
+      78             :     {
+      79         578 :         LG_TRY (LAGraph_Cached_AT (G, msg)) ;
+      80             :     }
+      81             : 
+      82             :     //--------------------------------------------------------------------------
+      83             :     // check if the structure of A and AT are the same
+      84             :     //--------------------------------------------------------------------------
+      85             : 
+      86         827 :     GRB_TRY (GrB_Matrix_new (&C, GrB_BOOL, n, n)) ;
+      87             : 
+      88             :     // C(i,j) = 1 if both A(i,j) and AT(i,j) exist
+      89         625 :     GRB_TRY (GrB_eWiseMult (C, NULL, NULL, GrB_ONEB_BOOL, A, G->AT, NULL)) ;
+      90             : 
+      91             :     GrB_Index nvals1, nvals2 ;
+      92         478 :     GRB_TRY (GrB_Matrix_nvals (&nvals1, C)) ;
+      93         478 :     GRB_TRY (GrB_Matrix_nvals (&nvals2, A)) ;
+      94         478 :     G->is_symmetric_structure =
+      95         478 :         (nvals1 == nvals2) ? LAGraph_TRUE : LAGraph_FALSE ;
+      96             : 
+      97             :     //--------------------------------------------------------------------------
+      98             :     // free workspace and return result
+      99             :     //--------------------------------------------------------------------------
+     100             : 
+     101         478 :     LG_FREE_WORK ;
+     102         478 :     return (GrB_SUCCESS) ;
+     103             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Cached_NSelfEdges.c.func-sort-c.html b/src/utility/LAGraph_Cached_NSelfEdges.c.func-sort-c.html new file mode 100644 index 0000000000..50dcf5669e --- /dev/null +++ b/src/utility/LAGraph_Cached_NSelfEdges.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Cached_NSelfEdges.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Cached_NSelfEdges.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:55100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_Cached_NSelfEdges985
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Cached_NSelfEdges.c.func.html b/src/utility/LAGraph_Cached_NSelfEdges.c.func.html new file mode 100644 index 0000000000..e77ad48f69 --- /dev/null +++ b/src/utility/LAGraph_Cached_NSelfEdges.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Cached_NSelfEdges.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Cached_NSelfEdges.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:55100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_Cached_NSelfEdges985
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Cached_NSelfEdges.c.gcov.html b/src/utility/LAGraph_Cached_NSelfEdges.c.gcov.html new file mode 100644 index 0000000000..88b1413331 --- /dev/null +++ b/src/utility/LAGraph_Cached_NSelfEdges.c.gcov.html @@ -0,0 +1,121 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Cached_NSelfEdges.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Cached_NSelfEdges.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:55100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_Cached_NSelfEdges: count the # of diagonal entries of a graph
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include "LG_internal.h"
+      19             : 
+      20         985 : int LAGraph_Cached_NSelfEdges
+      21             : (
+      22             :     // input/output:
+      23             :     LAGraph_Graph G,    // graph to compute G->nself_edges
+      24             :     char *msg
+      25             : )
+      26             : {
+      27             : 
+      28             :     //--------------------------------------------------------------------------
+      29             :     // clear msg and check G
+      30             :     //--------------------------------------------------------------------------
+      31             : 
+      32         985 :     LG_CLEAR_MSG_AND_BASIC_ASSERT (G, msg) ;
+      33             : 
+      34             :     // already computed
+      35         984 :     if (G->nself_edges != LAGRAPH_UNKNOWN)
+      36             :     {
+      37         352 :         return (GrB_SUCCESS) ;
+      38             :     }
+      39             : 
+      40             :     //--------------------------------------------------------------------------
+      41             :     // compute G->nself_edges
+      42             :     //--------------------------------------------------------------------------
+      43             : 
+      44         632 :     return (LG_nself_edges (&G->nself_edges, G->A, msg)) ;
+      45             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Cached_OutDegree.c.func-sort-c.html b/src/utility/LAGraph_Cached_OutDegree.c.func-sort-c.html new file mode 100644 index 0000000000..c74fd2150e --- /dev/null +++ b/src/utility/LAGraph_Cached_OutDegree.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Cached_OutDegree.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Cached_OutDegree.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1515100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_Cached_OutDegree1583
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Cached_OutDegree.c.func.html b/src/utility/LAGraph_Cached_OutDegree.c.func.html new file mode 100644 index 0000000000..887b9d2710 --- /dev/null +++ b/src/utility/LAGraph_Cached_OutDegree.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Cached_OutDegree.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Cached_OutDegree.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1515100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_Cached_OutDegree1583
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Cached_OutDegree.c.gcov.html b/src/utility/LAGraph_Cached_OutDegree.c.gcov.html new file mode 100644 index 0000000000..5904ca2668 --- /dev/null +++ b/src/utility/LAGraph_Cached_OutDegree.c.gcov.html @@ -0,0 +1,158 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Cached_OutDegree.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Cached_OutDegree.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1515100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_Cached_OutDegree: determine G->out_degree
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // LAGraph_Cached_OutDegree computes G->out_degree, where G->out_degree(i) is
+      19             : // the number of entries in G->A (i,:).  If there are no entries in G->A (i,:),
+      20             : // G->rowdgree(i) is not present in the structure of G->out_degree.  That is,
+      21             : // G->out_degree contains no explicit zero entries.
+      22             : 
+      23             : #define LG_FREE_WORK            \
+      24             : {                               \
+      25             :     GrB_free (&x) ;             \
+      26             : }
+      27             : 
+      28             : #define LG_FREE_ALL             \
+      29             : {                               \
+      30             :     LG_FREE_WORK ;              \
+      31             :     GrB_free (&out_degree) ;    \
+      32             : }
+      33             : 
+      34             : #include "LG_internal.h"
+      35             : 
+      36        1583 : int LAGraph_Cached_OutDegree
+      37             : (
+      38             :     // input/output:
+      39             :     LAGraph_Graph G,    // graph to determine G->out_degree
+      40             :     char *msg
+      41             : )
+      42             : {
+      43             : 
+      44             :     //--------------------------------------------------------------------------
+      45             :     // clear msg and check G
+      46             :     //--------------------------------------------------------------------------
+      47             : 
+      48        1583 :     GrB_Vector out_degree = NULL, x = NULL ;
+      49        1583 :     LG_CLEAR_MSG_AND_BASIC_ASSERT (G, msg) ;
+      50             : 
+      51        1582 :     if (G->out_degree != NULL)
+      52             :     {
+      53             :         // G->out_degree already computed
+      54         538 :         return (GrB_SUCCESS) ;
+      55             :     }
+      56             : 
+      57             :     //--------------------------------------------------------------------------
+      58             :     // determine the size of A
+      59             :     //--------------------------------------------------------------------------
+      60             : 
+      61        1044 :     GrB_Matrix A = G->A ;
+      62             :     GrB_Index nrows, ncols ;
+      63        1044 :     GRB_TRY (GrB_Matrix_nrows (&nrows, A)) ;
+      64        1044 :     GRB_TRY (GrB_Matrix_ncols (&ncols, A)) ;
+      65             : 
+      66             :     //--------------------------------------------------------------------------
+      67             :     // compute the out_degree
+      68             :     //--------------------------------------------------------------------------
+      69             : 
+      70        1044 :     GRB_TRY (GrB_Vector_new (&out_degree, GrB_INT64, nrows)) ;
+      71             :     // x = zeros (ncols,1)
+      72         910 :     GRB_TRY (GrB_Vector_new (&x, GrB_INT64, ncols)) ;
+      73         776 :     GRB_TRY (GrB_assign (x, NULL, NULL, 0, GrB_ALL, ncols, NULL)) ;
+      74             : 
+      75         709 :     GRB_TRY (GrB_mxv (out_degree, NULL, NULL, LAGraph_plus_one_int64,
+      76             :         A, x, NULL)) ;
+      77             : 
+      78         590 :     G->out_degree = out_degree ;
+      79             : 
+      80         590 :     LG_FREE_WORK ;
+      81         590 :     return (GrB_SUCCESS) ;
+      82             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Calloc.c.func-sort-c.html b/src/utility/LAGraph_Calloc.c.func-sort-c.html new file mode 100644 index 0000000000..5ed2dc0814 --- /dev/null +++ b/src/utility/LAGraph_Calloc.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Calloc.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Calloc.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1414100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_Calloc2548
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Calloc.c.func.html b/src/utility/LAGraph_Calloc.c.func.html new file mode 100644 index 0000000000..90529b5377 --- /dev/null +++ b/src/utility/LAGraph_Calloc.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Calloc.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Calloc.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1414100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_Calloc2548
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Calloc.c.gcov.html b/src/utility/LAGraph_Calloc.c.gcov.html new file mode 100644 index 0000000000..3dde160207 --- /dev/null +++ b/src/utility/LAGraph_Calloc.c.gcov.html @@ -0,0 +1,136 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Calloc.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Calloc.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1414100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_Calloc:  wrapper for calloc
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include "LG_internal.h"
+      19             : 
+      20        2548 : int LAGraph_Calloc
+      21             : (
+      22             :     // output:
+      23             :     void **p,               // pointer to allocated block of memory
+      24             :     // input:
+      25             :     size_t nitems,          // number of items
+      26             :     size_t size_of_item,    // size of each item
+      27             :     char *msg
+      28             : )
+      29             : {
+      30             :     // check inputs
+      31        2548 :     LG_CLEAR_MSG ;
+      32        2548 :     LG_ASSERT (p != NULL, GrB_NULL_POINTER) ;
+      33        2548 :     (*p) = NULL ;
+      34             : 
+      35             :     // make sure at least one item is allocated
+      36        2548 :     nitems = LAGRAPH_MAX (1, nitems) ;
+      37             : 
+      38             :     // make sure at least one byte is allocated
+      39        2548 :     size_of_item = LAGRAPH_MAX (1, size_of_item) ;
+      40             : 
+      41             :     // compute the size and check for integer overflow
+      42             :     size_t size ;
+      43        2548 :     if (!LG_Multiply_size_t (&size, nitems, size_of_item))
+      44             :     {
+      45             :         // overflow
+      46           1 :         return (GrB_OUT_OF_MEMORY) ;
+      47             :     }
+      48             : 
+      49        2547 :     if (LAGraph_Calloc_function == NULL)
+      50             :     {
+      51             :         // calloc function not available; use malloc and memset
+      52           1 :         LG_TRY (LAGraph_Malloc (p, nitems, size_of_item, msg)) ;
+      53           1 :         memset (*p, 0, size) ;
+      54           1 :         return (GrB_SUCCESS) ;
+      55             :     }
+      56             : 
+      57             :     // use the calloc function
+      58        2546 :     (*p) = LAGraph_Calloc_function (nitems, size_of_item) ;
+      59        2546 :     return (((*p) == NULL) ? GrB_OUT_OF_MEMORY : GrB_SUCCESS) ;
+      60             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_CheckGraph.c.func-sort-c.html b/src/utility/LAGraph_CheckGraph.c.func-sort-c.html new file mode 100644 index 0000000000..2a6a40f7bd --- /dev/null +++ b/src/utility/LAGraph_CheckGraph.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_CheckGraph.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_CheckGraph.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3333100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_CheckGraph33187
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_CheckGraph.c.func.html b/src/utility/LAGraph_CheckGraph.c.func.html new file mode 100644 index 0000000000..0425af8245 --- /dev/null +++ b/src/utility/LAGraph_CheckGraph.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_CheckGraph.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_CheckGraph.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3333100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_CheckGraph33187
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_CheckGraph.c.gcov.html b/src/utility/LAGraph_CheckGraph.c.gcov.html new file mode 100644 index 0000000000..43ce2941b2 --- /dev/null +++ b/src/utility/LAGraph_CheckGraph.c.gcov.html @@ -0,0 +1,193 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_CheckGraph.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_CheckGraph.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3333100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_CheckGraph: check if a graph is valid
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include "LG_internal.h"
+      19             : 
+      20       33187 : int LAGraph_CheckGraph
+      21             : (
+      22             :     // input/output:
+      23             :     LAGraph_Graph G,    // graph to check
+      24             :     char *msg
+      25             : )
+      26             : {
+      27             : 
+      28             :     //--------------------------------------------------------------------------
+      29             :     // clear the msg and check basic components
+      30             :     //--------------------------------------------------------------------------
+      31             : 
+      32       33187 :     LG_CLEAR_MSG_AND_BASIC_ASSERT (G, msg) ;
+      33       33172 :     GrB_Matrix A = G->A ;
+      34       33172 :     LAGraph_Kind kind = G->kind ;
+      35             : 
+      36             :     //--------------------------------------------------------------------------
+      37             :     // ensure the matrix is square for directed or undirected graphs
+      38             :     //--------------------------------------------------------------------------
+      39             : 
+      40             :     GrB_Index nrows, ncols ;
+      41       33172 :     if (kind == LAGraph_ADJACENCY_UNDIRECTED ||
+      42             :         kind == LAGraph_ADJACENCY_DIRECTED)
+      43             :     {
+      44       33172 :         GRB_TRY (GrB_Matrix_nrows (&nrows, A)) ;
+      45       33172 :         GRB_TRY (GrB_Matrix_ncols (&ncols, A)) ;
+      46       33172 :         LG_ASSERT_MSG (nrows == ncols, LAGRAPH_INVALID_GRAPH,
+      47             :             "adjacency matrix must be square") ;
+      48             :     }
+      49             : 
+      50             :     #if LAGRAPH_SUITESPARSE
+      51             :         // only by-row format is supported when using SuiteSparse
+      52             :         GxB_Format_Value fmt ;
+      53       33171 :         GRB_TRY (GxB_get (A, GxB_FORMAT, &fmt)) ;
+      54       33171 :         LG_ASSERT_MSG (fmt == GxB_BY_ROW, LAGRAPH_INVALID_GRAPH,
+      55             :             "only by-row format supported") ;
+      56             :     #endif
+      57             : 
+      58             :     //--------------------------------------------------------------------------
+      59             :     // check the cached properties
+      60             :     //--------------------------------------------------------------------------
+      61             : 
+      62       33170 :     GrB_Matrix AT = G->AT ;
+      63       33170 :     if (AT != NULL)
+      64             :     {
+      65             :         GrB_Index nrows2, ncols2;
+      66        6464 :         GRB_TRY (GrB_Matrix_nrows (&nrows2, AT)) ;
+      67        6458 :         GRB_TRY (GrB_Matrix_ncols (&ncols2, AT)) ;
+      68        6458 :         LG_ASSERT_MSG (nrows == ncols2 && ncols == nrows2,
+      69             :             LAGRAPH_INVALID_GRAPH, "G->AT matrix has the wrong dimensions") ;
+      70             : 
+      71             :         #if LAGRAPH_SUITESPARSE
+      72             :             // only by-row format is supported when using SuiteSparse
+      73             :             GxB_Format_Value fmt ;
+      74        6456 :             GRB_TRY (GxB_get (AT, GxB_FORMAT, &fmt)) ;
+      75        6456 :             LG_ASSERT_MSG (fmt == GxB_BY_ROW,
+      76             :                 LAGRAPH_INVALID_GRAPH, "only by-row format supported") ;
+      77             :         #endif
+      78             : 
+      79             :         // ensure the types of A and AT are the same
+      80             :         char atype [LAGRAPH_MAX_NAME_LEN] ;
+      81             :         char ttype [LAGRAPH_MAX_NAME_LEN] ;
+      82        6454 :         LG_TRY (LAGraph_Matrix_TypeName (atype, A, msg)) ;
+      83        6454 :         LG_TRY (LAGraph_Matrix_TypeName (ttype, AT, msg)) ;
+      84        6454 :         LG_ASSERT_MSG (MATCHNAME (atype, ttype),
+      85             :             LAGRAPH_INVALID_GRAPH, "A and AT must have the same type") ;
+      86             :     }
+      87             : 
+      88       33164 :     GrB_Vector out_degree = G->out_degree ;
+      89       33164 :     if (out_degree != NULL)
+      90             :     {
+      91             :         GrB_Index m ;
+      92       17444 :         GRB_TRY (GrB_Vector_size (&m, out_degree)) ;
+      93       17442 :         LG_ASSERT_MSG (m == nrows, LAGRAPH_INVALID_GRAPH,
+      94             :             "out_degree invalid size") ;
+      95             :         char rtype [LAGRAPH_MAX_NAME_LEN] ;
+      96       17441 :         LG_TRY (LAGraph_Vector_TypeName (rtype, out_degree, msg)) ;
+      97       17441 :         LG_ASSERT_MSG (MATCHNAME (rtype, "int64_t"),
+      98             :             LAGRAPH_INVALID_GRAPH,
+      99             :             "out_degree has wrong type; must be GrB_INT64") ;
+     100             :     }
+     101             : 
+     102       33162 :     GrB_Vector in_degree = G->in_degree ;
+     103       33162 :     if (in_degree != NULL)
+     104             :     {
+     105             :         GrB_Index n ;
+     106        6274 :         GRB_TRY (GrB_Vector_size (&n, in_degree)) ;
+     107        6272 :         LG_ASSERT_MSG (n == ncols, LAGRAPH_INVALID_GRAPH,
+     108             :             "in_degree invalid size") ;
+     109             :         char ctype [LAGRAPH_MAX_NAME_LEN] ;
+     110        6271 :         LG_TRY (LAGraph_Vector_TypeName (ctype, in_degree, msg)) ;
+     111        6271 :         LG_ASSERT_MSG (MATCHNAME (ctype, "int64_t"),
+     112             :             LAGRAPH_INVALID_GRAPH,
+     113             :             "in_degree has wrong type; must be GrB_INT64") ;
+     114             :     }
+     115             : 
+     116       33160 :     return (GrB_SUCCESS) ;
+     117             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Delete.c.func-sort-c.html b/src/utility/LAGraph_Delete.c.func-sort-c.html new file mode 100644 index 0000000000..243a151cb4 --- /dev/null +++ b/src/utility/LAGraph_Delete.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Delete.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Delete.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:88100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_Delete1136
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Delete.c.func.html b/src/utility/LAGraph_Delete.c.func.html new file mode 100644 index 0000000000..6ef734ee7d --- /dev/null +++ b/src/utility/LAGraph_Delete.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Delete.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Delete.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:88100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_Delete1136
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Delete.c.gcov.html b/src/utility/LAGraph_Delete.c.gcov.html new file mode 100644 index 0000000000..23db5b8ed2 --- /dev/null +++ b/src/utility/LAGraph_Delete.c.gcov.html @@ -0,0 +1,132 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Delete.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Delete.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:88100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_Delete: deletes a graph and all its contents
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include "LG_internal.h"
+      19             : 
+      20        1136 : int LAGraph_Delete
+      21             : (
+      22             :     // input/output:
+      23             :     LAGraph_Graph *G,   // the graph to delete; G set to NULL on output.
+      24             :                         // All internal GrB_Matrix and GrB_Vector objects are
+      25             :                         // freed, including G->A.  To keep G->A while deleting
+      26             :                         // the graph G, use:
+      27             :                         // { A = G->A ; G->A = NULL ; LAGraph_Delete (&G, msg);}
+      28             :     char *msg
+      29             : )
+      30             : {
+      31             : 
+      32             :     //--------------------------------------------------------------------------
+      33             :     // check inputs
+      34             :     //--------------------------------------------------------------------------
+      35             : 
+      36        1136 :     LG_CLEAR_MSG ;
+      37        1136 :     if (G == NULL || (*G) == NULL)
+      38             :     {
+      39             :         // success: nothing to do
+      40           3 :         return (GrB_SUCCESS) ;
+      41             :     }
+      42             : 
+      43             :     //--------------------------------------------------------------------------
+      44             :     // free the cached contents of the graph
+      45             :     //--------------------------------------------------------------------------
+      46             : 
+      47        1133 :     LG_TRY (LAGraph_DeleteCached (*G, msg)) ;
+      48             : 
+      49             :     //--------------------------------------------------------------------------
+      50             :     // delete the primary contents of the graph, and the graph itself
+      51             :     //--------------------------------------------------------------------------
+      52             : 
+      53        1133 :     GRB_TRY (GrB_free (&((*G)->A))) ;
+      54        1133 :     LAGraph_Free ((void **) G, NULL) ;
+      55        1133 :     return (GrB_SUCCESS) ;
+      56             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_DeleteCached.c.func-sort-c.html b/src/utility/LAGraph_DeleteCached.c.func-sort-c.html new file mode 100644 index 0000000000..25851cce19 --- /dev/null +++ b/src/utility/LAGraph_DeleteCached.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_DeleteCached.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_DeleteCached.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1616100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_DeleteCached1527
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_DeleteCached.c.func.html b/src/utility/LAGraph_DeleteCached.c.func.html new file mode 100644 index 0000000000..f2f6b5ffe2 --- /dev/null +++ b/src/utility/LAGraph_DeleteCached.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_DeleteCached.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_DeleteCached.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1616100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_DeleteCached1527
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_DeleteCached.c.gcov.html b/src/utility/LAGraph_DeleteCached.c.gcov.html new file mode 100644 index 0000000000..752bfe9b8f --- /dev/null +++ b/src/utility/LAGraph_DeleteCached.c.gcov.html @@ -0,0 +1,137 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_DeleteCached.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_DeleteCached.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1616100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_DeleteCached: deletes the cached properties of a graph
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include "LG_internal.h"
+      19             : 
+      20        1527 : int LAGraph_DeleteCached
+      21             : (
+      22             :     // input/output:
+      23             :     LAGraph_Graph G,    // G stays valid, only cached properties are freed
+      24             :     char *msg
+      25             : )
+      26             : {
+      27             : 
+      28             :     //--------------------------------------------------------------------------
+      29             :     // check inputs
+      30             :     //--------------------------------------------------------------------------
+      31             : 
+      32        1527 :     LG_CLEAR_MSG ;
+      33        1527 :     if (G == NULL)
+      34             :     {
+      35             :         // success: nothing to do
+      36           6 :         return (GrB_SUCCESS) ;
+      37             :     }
+      38             : 
+      39             :     //--------------------------------------------------------------------------
+      40             :     // free all cached properties of the graph
+      41             :     //--------------------------------------------------------------------------
+      42             : 
+      43        1521 :     GRB_TRY (GrB_free (&(G->AT))) ;
+      44        1521 :     GRB_TRY (GrB_free (&(G->out_degree))) ;
+      45        1521 :     GRB_TRY (GrB_free (&(G->in_degree))) ;
+      46        1521 :     GRB_TRY (GrB_free (&(G->emin))) ;
+      47        1521 :     GRB_TRY (GrB_free (&(G->emax))) ;
+      48             : 
+      49             :     //--------------------------------------------------------------------------
+      50             :     // clear the cached scalar properties of the graph
+      51             :     //--------------------------------------------------------------------------
+      52             : 
+      53        1521 :     G->is_symmetric_structure =
+      54        1521 :         (G->kind == LAGraph_ADJACENCY_UNDIRECTED)
+      55             :         ? LAGraph_TRUE
+      56        1521 :         : LAGRAPH_UNKNOWN ;
+      57        1521 :     G->emin_state = LAGRAPH_UNKNOWN ;
+      58        1521 :     G->emax_state = LAGRAPH_UNKNOWN ;
+      59        1521 :     G->nself_edges = LAGRAPH_UNKNOWN ;
+      60        1521 :     return (GrB_SUCCESS) ;
+      61             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_DeleteSelfEdges.c.func-sort-c.html b/src/utility/LAGraph_DeleteSelfEdges.c.func-sort-c.html new file mode 100644 index 0000000000..a6acdd92b5 --- /dev/null +++ b/src/utility/LAGraph_DeleteSelfEdges.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_DeleteSelfEdges.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_DeleteSelfEdges.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1010100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_DeleteSelfEdges45
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_DeleteSelfEdges.c.func.html b/src/utility/LAGraph_DeleteSelfEdges.c.func.html new file mode 100644 index 0000000000..de8d467e86 --- /dev/null +++ b/src/utility/LAGraph_DeleteSelfEdges.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_DeleteSelfEdges.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_DeleteSelfEdges.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1010100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_DeleteSelfEdges45
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_DeleteSelfEdges.c.gcov.html b/src/utility/LAGraph_DeleteSelfEdges.c.gcov.html new file mode 100644 index 0000000000..c42368f737 --- /dev/null +++ b/src/utility/LAGraph_DeleteSelfEdges.c.gcov.html @@ -0,0 +1,135 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_DeleteSelfEdges.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_DeleteSelfEdges.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1010100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_DeleteSelfEdges: removes the diagonal entries from G->A
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include "LG_internal.h"
+      19             : 
+      20          45 : int LAGraph_DeleteSelfEdges
+      21             : (
+      22             :     // input/output:
+      23             :     LAGraph_Graph G,    // diagonal entries removed, most cached properties cleared
+      24             :     char *msg
+      25             : )
+      26             : {
+      27             : 
+      28             :     //--------------------------------------------------------------------------
+      29             :     // clear msg and check G
+      30             :     //--------------------------------------------------------------------------
+      31             : 
+      32          45 :     LG_CLEAR_MSG_AND_BASIC_ASSERT (G, msg) ;
+      33          45 :     if (G->nself_edges == 0)
+      34             :     {
+      35             :         // nothing to do
+      36           9 :         return (GrB_SUCCESS) ;
+      37             :     }
+      38             : 
+      39             :     //--------------------------------------------------------------------------
+      40             :     // delete all cached properties not affected by the removal of the diagonal
+      41             :     //--------------------------------------------------------------------------
+      42             : 
+      43          36 :     LAGraph_Boolean is_symmetric_structure = G->is_symmetric_structure ;
+      44          36 :     LG_TRY (LAGraph_DeleteCached (G, msg)) ;
+      45          36 :     G->is_symmetric_structure = is_symmetric_structure ;
+      46             : 
+      47             :     //--------------------------------------------------------------------------
+      48             :     // remove diagonal entries
+      49             :     //--------------------------------------------------------------------------
+      50             : 
+      51          36 :     GRB_TRY (GrB_select (G->A, NULL, NULL, GrB_OFFDIAG, G->A, 0, NULL)) ;
+      52             : 
+      53             :     //--------------------------------------------------------------------------
+      54             :     // free workspace, G->nself_edges now known to be zero
+      55             :     //--------------------------------------------------------------------------
+      56             : 
+      57          36 :     G->nself_edges = 0 ;
+      58          36 :     return (GrB_SUCCESS) ;
+      59             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Finalize.c.func-sort-c.html b/src/utility/LAGraph_Finalize.c.func-sort-c.html new file mode 100644 index 0000000000..7d721498cc --- /dev/null +++ b/src/utility/LAGraph_Finalize.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Finalize.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Finalize.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:4545100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_Finalize224
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Finalize.c.func.html b/src/utility/LAGraph_Finalize.c.func.html new file mode 100644 index 0000000000..a7c18dc13d --- /dev/null +++ b/src/utility/LAGraph_Finalize.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Finalize.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Finalize.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:4545100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_Finalize224
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Finalize.c.gcov.html b/src/utility/LAGraph_Finalize.c.gcov.html new file mode 100644 index 0000000000..011851b853 --- /dev/null +++ b/src/utility/LAGraph_Finalize.c.gcov.html @@ -0,0 +1,160 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Finalize.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Finalize.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:4545100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_Finalize: finish LAGraph
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include "LG_internal.h"
+      19             : 
+      20         224 : int LAGraph_Finalize (char *msg)
+      21             : {
+      22             : 
+      23             :     //--------------------------------------------------------------------------
+      24             :     // check inputs
+      25             :     //--------------------------------------------------------------------------
+      26             : 
+      27         224 :     LG_CLEAR_MSG ;
+      28             : 
+      29             :     //--------------------------------------------------------------------------
+      30             :     // free global objects
+      31             :     //--------------------------------------------------------------------------
+      32             : 
+      33         224 :     GRB_TRY (GrB_Semiring_free (&LAGraph_plus_first_int8  )) ;
+      34         224 :     GRB_TRY (GrB_Semiring_free (&LAGraph_plus_first_int16 )) ;
+      35         224 :     GRB_TRY (GrB_Semiring_free (&LAGraph_plus_first_int32 )) ;
+      36         224 :     GRB_TRY (GrB_Semiring_free (&LAGraph_plus_first_int64 )) ;
+      37         224 :     GRB_TRY (GrB_Semiring_free (&LAGraph_plus_first_uint8 )) ;
+      38         224 :     GRB_TRY (GrB_Semiring_free (&LAGraph_plus_first_uint16)) ;
+      39         224 :     GRB_TRY (GrB_Semiring_free (&LAGraph_plus_first_uint32)) ;
+      40         224 :     GRB_TRY (GrB_Semiring_free (&LAGraph_plus_first_uint64)) ;
+      41         224 :     GRB_TRY (GrB_Semiring_free (&LAGraph_plus_first_fp32  )) ;
+      42         224 :     GRB_TRY (GrB_Semiring_free (&LAGraph_plus_first_fp64  )) ;
+      43             : 
+      44         224 :     GRB_TRY (GrB_Semiring_free (&LAGraph_plus_second_int8  )) ;
+      45         224 :     GRB_TRY (GrB_Semiring_free (&LAGraph_plus_second_int16 )) ;
+      46         224 :     GRB_TRY (GrB_Semiring_free (&LAGraph_plus_second_int32 )) ;
+      47         224 :     GRB_TRY (GrB_Semiring_free (&LAGraph_plus_second_int64 )) ;
+      48         224 :     GRB_TRY (GrB_Semiring_free (&LAGraph_plus_second_uint8 )) ;
+      49         224 :     GRB_TRY (GrB_Semiring_free (&LAGraph_plus_second_uint16)) ;
+      50         224 :     GRB_TRY (GrB_Semiring_free (&LAGraph_plus_second_uint32)) ;
+      51         224 :     GRB_TRY (GrB_Semiring_free (&LAGraph_plus_second_uint64)) ;
+      52         224 :     GRB_TRY (GrB_Semiring_free (&LAGraph_plus_second_fp32  )) ;
+      53         224 :     GRB_TRY (GrB_Semiring_free (&LAGraph_plus_second_fp64  )) ;
+      54             : 
+      55         224 :     GRB_TRY (GrB_Semiring_free (&LAGraph_plus_one_int8  )) ;
+      56         224 :     GRB_TRY (GrB_Semiring_free (&LAGraph_plus_one_int16 )) ;
+      57         224 :     GRB_TRY (GrB_Semiring_free (&LAGraph_plus_one_int32 )) ;
+      58         224 :     GRB_TRY (GrB_Semiring_free (&LAGraph_plus_one_int64 )) ;
+      59         224 :     GRB_TRY (GrB_Semiring_free (&LAGraph_plus_one_uint8 )) ;
+      60         224 :     GRB_TRY (GrB_Semiring_free (&LAGraph_plus_one_uint16)) ;
+      61         224 :     GRB_TRY (GrB_Semiring_free (&LAGraph_plus_one_uint32)) ;
+      62         224 :     GRB_TRY (GrB_Semiring_free (&LAGraph_plus_one_uint64)) ;
+      63         224 :     GRB_TRY (GrB_Semiring_free (&LAGraph_plus_one_fp32  )) ;
+      64         224 :     GRB_TRY (GrB_Semiring_free (&LAGraph_plus_one_fp64  )) ;
+      65             : 
+      66         224 :     GRB_TRY (GrB_Semiring_free (&LAGraph_any_one_bool  )) ;
+      67         224 :     GRB_TRY (GrB_Semiring_free (&LAGraph_any_one_int8  )) ;
+      68         224 :     GRB_TRY (GrB_Semiring_free (&LAGraph_any_one_int16 )) ;
+      69         224 :     GRB_TRY (GrB_Semiring_free (&LAGraph_any_one_int32 )) ;
+      70         224 :     GRB_TRY (GrB_Semiring_free (&LAGraph_any_one_int64 )) ;
+      71         224 :     GRB_TRY (GrB_Semiring_free (&LAGraph_any_one_uint8 )) ;
+      72         224 :     GRB_TRY (GrB_Semiring_free (&LAGraph_any_one_uint16)) ;
+      73         224 :     GRB_TRY (GrB_Semiring_free (&LAGraph_any_one_uint32)) ;
+      74         224 :     GRB_TRY (GrB_Semiring_free (&LAGraph_any_one_uint64)) ;
+      75         224 :     GRB_TRY (GrB_Semiring_free (&LAGraph_any_one_fp32  )) ;
+      76         224 :     GRB_TRY (GrB_Semiring_free (&LAGraph_any_one_fp64  )) ;
+      77             : 
+      78             :     //--------------------------------------------------------------------------
+      79             :     // finalize GraphBLAS
+      80             :     //--------------------------------------------------------------------------
+      81             : 
+      82         224 :     GRB_TRY (GrB_finalize ( )) ;
+      83         224 :     return (GrB_SUCCESS) ;
+      84             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Free.c.func-sort-c.html b/src/utility/LAGraph_Free.c.func-sort-c.html new file mode 100644 index 0000000000..c764de1c40 --- /dev/null +++ b/src/utility/LAGraph_Free.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Free.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Free.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:66100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_Free46008
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Free.c.func.html b/src/utility/LAGraph_Free.c.func.html new file mode 100644 index 0000000000..e6ea2c1174 --- /dev/null +++ b/src/utility/LAGraph_Free.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Free.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Free.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:66100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_Free46008
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Free.c.gcov.html b/src/utility/LAGraph_Free.c.gcov.html new file mode 100644 index 0000000000..05a2d88059 --- /dev/null +++ b/src/utility/LAGraph_Free.c.gcov.html @@ -0,0 +1,115 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Free.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Free.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:66100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_Free:  wrapper for free
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // LAGraph_Free frees a block of memory obtained by LAGraph_Malloc.  It does
+      19             : // nothing if p is NULL.
+      20             : 
+      21             : #include "LG_internal.h"
+      22             : 
+      23       46008 : int LAGraph_Free            // free a block of memory and set p to NULL
+      24             : (
+      25             :     // input/output:
+      26             :     void **p,               // pointer to object to free, does nothing if NULL
+      27             :     char *msg
+      28             : )
+      29             : {
+      30       46008 :     LG_CLEAR_MSG ;
+      31             : 
+      32       46008 :     if (p != NULL && (*p) != NULL)
+      33             :     {
+      34       28769 :         LAGraph_Free_function (*p) ;
+      35       28769 :         (*p) = NULL ;
+      36             :     }
+      37             : 
+      38       46008 :     return (GrB_SUCCESS) ;
+      39             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_GetNumThreads.c.func-sort-c.html b/src/utility/LAGraph_GetNumThreads.c.func-sort-c.html new file mode 100644 index 0000000000..91012d4704 --- /dev/null +++ b/src/utility/LAGraph_GetNumThreads.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_GetNumThreads.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_GetNumThreads.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:66100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_GetNumThreads113
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_GetNumThreads.c.func.html b/src/utility/LAGraph_GetNumThreads.c.func.html new file mode 100644 index 0000000000..2108d19746 --- /dev/null +++ b/src/utility/LAGraph_GetNumThreads.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_GetNumThreads.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_GetNumThreads.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:66100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_GetNumThreads113
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_GetNumThreads.c.gcov.html b/src/utility/LAGraph_GetNumThreads.c.gcov.html new file mode 100644 index 0000000000..65e6a9939f --- /dev/null +++ b/src/utility/LAGraph_GetNumThreads.c.gcov.html @@ -0,0 +1,122 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_GetNumThreads.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_GetNumThreads.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:66100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_GetNumThreads: get the # of threads to use
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // LAGraph_get_nthreads: get # of threads that will be used by LAGraph.
+      19             : 
+      20             : #include "LG_internal.h"
+      21             : 
+      22         113 : int LAGraph_GetNumThreads
+      23             : (
+      24             :     // output:
+      25             :     int *nthreads_outer,
+      26             :     int *nthreads_inner,
+      27             :     char *msg
+      28             : )
+      29             : {
+      30             : 
+      31             :     //--------------------------------------------------------------------------
+      32             :     // check inputs
+      33             :     //--------------------------------------------------------------------------
+      34             : 
+      35         113 :     LG_CLEAR_MSG ;
+      36         113 :     LG_ASSERT (nthreads_outer != NULL && nthreads_inner != NULL,
+      37             :         GrB_NULL_POINTER) ;
+      38             : 
+      39             :     //--------------------------------------------------------------------------
+      40             :     // get number of threads
+      41             :     //--------------------------------------------------------------------------
+      42             : 
+      43         112 :     (*nthreads_outer) = LG_nthreads_outer ;
+      44         112 :     (*nthreads_inner) = LG_nthreads_inner ;
+      45         112 :     return (GrB_SUCCESS) ;
+      46             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Graph_Print.c.func-sort-c.html b/src/utility/LAGraph_Graph_Print.c.func-sort-c.html new file mode 100644 index 0000000000..4a5919d1aa --- /dev/null +++ b/src/utility/LAGraph_Graph_Print.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Graph_Print.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Graph_Print.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3939100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_Graph_Print350
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Graph_Print.c.func.html b/src/utility/LAGraph_Graph_Print.c.func.html new file mode 100644 index 0000000000..0191d51bf6 --- /dev/null +++ b/src/utility/LAGraph_Graph_Print.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Graph_Print.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Graph_Print.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3939100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_Graph_Print350
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Graph_Print.c.gcov.html b/src/utility/LAGraph_Graph_Print.c.gcov.html new file mode 100644 index 0000000000..54a5000af3 --- /dev/null +++ b/src/utility/LAGraph_Graph_Print.c.gcov.html @@ -0,0 +1,182 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Graph_Print.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Graph_Print.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3939100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_Graph_Print: print the contents of a graph
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include "LG_internal.h"
+      19             : 
+      20         350 : int LAGraph_Graph_Print
+      21             : (
+      22             :     // input:
+      23             :     const LAGraph_Graph G,  // graph to display
+      24             :     LAGraph_PrintLevel pr,  // print level (0 to 5)
+      25             :     FILE *f,                // file to write to, must already be open
+      26             :     char *msg
+      27             : )
+      28             : {
+      29             : 
+      30             :     //--------------------------------------------------------------------------
+      31             :     // clear the msg and check the graph
+      32             :     //--------------------------------------------------------------------------
+      33             : 
+      34         350 :     LG_CLEAR_MSG ;
+      35         350 :     LG_ASSERT (f != NULL, GrB_NULL_POINTER) ;
+      36         350 :     LG_TRY (LAGraph_CheckGraph (G, msg)) ;
+      37         345 :     int prl = (int) pr ;
+      38         345 :     prl = LAGRAPH_MAX (prl, 0) ;
+      39         345 :     prl = LAGRAPH_MIN (prl, 5) ;
+      40         345 :     if (prl == 0) return (GrB_SUCCESS) ;
+      41             : 
+      42             :     //--------------------------------------------------------------------------
+      43             :     // display the primary graph components
+      44             :     //--------------------------------------------------------------------------
+      45             : 
+      46         329 :     GrB_Matrix A = G->A ;
+      47         329 :     LAGraph_Kind kind = G->kind ;
+      48             : 
+      49             :     GrB_Index n, nvals ;
+      50         329 :     GRB_TRY (GrB_Matrix_nrows (&n, A)) ;
+      51         329 :     GRB_TRY (GrB_Matrix_nvals (&nvals, A)) ;
+      52             :     char typename [LAGRAPH_MAX_NAME_LEN] ;
+      53             :     char kindname [LAGRAPH_MAX_NAME_LEN] ;
+      54         329 :     LG_TRY (LAGraph_Matrix_TypeName (typename, A, msg)) ;
+      55         329 :     LG_TRY (LG_KindName (kindname, kind, msg)) ;
+      56             : 
+      57             :     // print the basic cached scalar properties
+      58         329 :     FPRINTF (f, "Graph: kind: %s, nodes: %g entries: %g type: %s\n",
+      59             :         kindname, (double)n, (double)nvals, typename) ;
+      60             : 
+      61             :     // print the scalar cached properties
+      62         329 :     FPRINTF (f, "  structural symmetry: ") ;
+      63         329 :     switch (G->is_symmetric_structure)
+      64             :     {
+      65         128 :         case LAGraph_FALSE : FPRINTF (f, "unsymmetric") ; break ;
+      66         154 :         case LAGraph_TRUE  : FPRINTF (f, "symmetric")   ; break ;
+      67          47 :         default            : FPRINTF (f, "unknown")     ; break ;
+      68             :     }
+      69         329 :     if (G->nself_edges >= 0)
+      70             :     {
+      71          84 :         FPRINTF (f, "  self-edges: %g", (double) G->nself_edges) ;
+      72             :     }
+      73         329 :     FPRINTF (f, "\n") ;
+      74             : 
+      75         329 :     FPRINTF (f, "  adjacency matrix: ") ;
+      76             : 
+      77         329 :     LAGraph_PrintLevel pr2 = (LAGraph_PrintLevel) prl ;
+      78         329 :     LG_TRY (LAGraph_Matrix_Print (A, pr2, stdout, msg)) ;
+      79             : 
+      80             :     //--------------------------------------------------------------------------
+      81             :     // display the cached properties
+      82             :     //--------------------------------------------------------------------------
+      83             : 
+      84         269 :     GrB_Matrix AT = G->AT ;
+      85         269 :     if (AT != NULL)
+      86             :     {
+      87         172 :         FPRINTF (f, "  adjacency matrix transposed: ") ;
+      88         172 :         LG_TRY (LAGraph_Matrix_Print (AT, pr2, stdout, msg)) ;
+      89             :     }
+      90             : 
+      91         247 :     GrB_Vector out_degree = G->out_degree ;
+      92         247 :     if (out_degree != NULL)
+      93             :     {
+      94         181 :         FPRINTF (f, "  out degree: ") ;
+      95         181 :         LG_TRY (LAGraph_Vector_Print (out_degree, pr2, stdout, msg)) ;
+      96             :     }
+      97             : 
+      98         247 :     GrB_Vector in_degree = G->in_degree ;
+      99         247 :     if (in_degree != NULL)
+     100             :     {
+     101         125 :         FPRINTF (f, "  in degree: ") ;
+     102         125 :         LG_TRY (LAGraph_Vector_Print (in_degree, pr2, stdout, msg)) ;
+     103             :     }
+     104             : 
+     105         247 :     return (GrB_SUCCESS) ;
+     106             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Init.c.func-sort-c.html b/src/utility/LAGraph_Init.c.func-sort-c.html new file mode 100644 index 0000000000..12fbe18619 --- /dev/null +++ b/src/utility/LAGraph_Init.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Init.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Init.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:33100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_Init101
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Init.c.func.html b/src/utility/LAGraph_Init.c.func.html new file mode 100644 index 0000000000..2d8919ae42 --- /dev/null +++ b/src/utility/LAGraph_Init.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Init.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Init.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:33100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_Init101
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Init.c.gcov.html b/src/utility/LAGraph_Init.c.gcov.html new file mode 100644 index 0000000000..3c49dab118 --- /dev/null +++ b/src/utility/LAGraph_Init.c.gcov.html @@ -0,0 +1,103 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Init.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Init.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:33100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_Init: start GraphBLAS and LAGraph
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include "LG_internal.h"
+      19             : 
+      20         101 : int LAGraph_Init (char *msg)
+      21             : {
+      22             : 
+      23         101 :     LG_CLEAR_MSG ;
+      24             : 
+      25             :     // use GraphBLAS nonblocking mode, and ANSI C memory allocation functions
+      26         101 :     return (LAGr_Init (GrB_NONBLOCKING, malloc, calloc, realloc, free, msg)) ;
+      27             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_MMRead.c.func-sort-c.html b/src/utility/LAGraph_MMRead.c.func-sort-c.html new file mode 100644 index 0000000000..c49f242285 --- /dev/null +++ b/src/utility/LAGraph_MMRead.c.func-sort-c.html @@ -0,0 +1,100 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_MMRead.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_MMRead.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:332332100.0 %
Date:2024-08-29 20:08:04Functions:77100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
negate_scalar1340
LAGraph_MMRead1974
read_double3157602
read_entry4054330
is_blank_line4061578
get_line4065091
set_value6291344
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_MMRead.c.func.html b/src/utility/LAGraph_MMRead.c.func.html new file mode 100644 index 0000000000..200fe2a3fe --- /dev/null +++ b/src/utility/LAGraph_MMRead.c.func.html @@ -0,0 +1,100 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_MMRead.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_MMRead.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:332332100.0 %
Date:2024-08-29 20:08:04Functions:77100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_MMRead1974
get_line4065091
is_blank_line4061578
negate_scalar1340
read_double3157602
read_entry4054330
set_value6291344
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_MMRead.c.gcov.html b/src/utility/LAGraph_MMRead.c.gcov.html new file mode 100644 index 0000000000..0f0f60d449 --- /dev/null +++ b/src/utility/LAGraph_MMRead.c.gcov.html @@ -0,0 +1,1127 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_MMRead.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_MMRead.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:332332100.0 %
Date:2024-08-29 20:08:04Functions:77100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_MMRead: read a matrix from a Matrix Market file
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // LAGraph_MMRead: read a matrix from a Matrix Market file
+      19             : 
+      20             : // Parts of this code are from SuiteSparse/CHOLMOD/Check/cholmod_read.c, and
+      21             : // are used here by permission of the author of CHOLMOD/Check (T. A. Davis).
+      22             : 
+      23             : // The Matrix Market format is described at:
+      24             : // https://math.nist.gov/MatrixMarket/formats.html
+      25             : 
+      26             : // Return values:
+      27             : //  GrB_SUCCESS: input file and output matrix are valid
+      28             : //  LAGRAPH_IO_ERROR: the input file cannot be read or has invalid content
+      29             : //  GrB_NULL_POINTER:  A or f are NULL on input
+      30             : //  GrB_NOT_IMPLEMENTED: complex types not yet supported
+      31             : //  other: return values directly from GrB_* methods
+      32             : 
+      33             : #define LG_FREE_WORK                    \
+      34             : {                                       \
+      35             :     LAGraph_Free ((void **) &I, NULL) ; \
+      36             :     LAGraph_Free ((void **) &J, NULL) ; \
+      37             :     LAGraph_Free ((void **) &X, NULL) ; \
+      38             : }
+      39             : 
+      40             : #define LG_FREE_ALL                     \
+      41             : {                                       \
+      42             :     LG_FREE_WORK ;                      \
+      43             :     GrB_free (A) ;                      \
+      44             : }
+      45             : 
+      46             : #include "LG_internal.h"
+      47             : 
+      48             : //------------------------------------------------------------------------------
+      49             : // get_line
+      50             : //------------------------------------------------------------------------------
+      51             : 
+      52             : // Read one line of the file, return true if successful, false if EOF.
+      53             : // The string is returned in buf, converted to lower case.
+      54             : 
+      55     4065091 : static inline bool get_line
+      56             : (
+      57             :     FILE *f,        // file open for reading
+      58             :     char *buf       // size MAXLINE+1
+      59             : )
+      60             : {
+      61             : 
+      62             :     // check inputs
+      63             :     ASSERT (f != NULL) ;
+      64             :     ASSERT (buf != NULL) ;
+      65             : 
+      66             :     // read the line from the file
+      67     4065091 :     buf [0] = '\0' ;
+      68     4065091 :     buf [1] = '\0' ;
+      69     4065091 :     if (fgets (buf, MAXLINE, f) == NULL)
+      70             :     {
+      71             :         // EOF or other I/O error
+      72           1 :         return (false) ;
+      73             :     }
+      74     4065090 :     buf [MAXLINE] = '\0' ;
+      75             : 
+      76             :     // convert the string to lower case
+      77    75762804 :     for (int k = 0 ; k < MAXLINE && buf [k] != '\0' ; k++)
+      78             :     {
+      79    71697714 :         buf [k] = tolower (buf [k]) ;
+      80             :     }
+      81     4065090 :     return (true) ;
+      82             : }
+      83             : 
+      84             : //------------------------------------------------------------------------------
+      85             : // is_blank_line
+      86             : //------------------------------------------------------------------------------
+      87             : 
+      88             : // returns true if buf is a blank line or comment, false otherwise.
+      89             : 
+      90     4061578 : static inline bool is_blank_line
+      91             : (
+      92             :     char *buf       // size MAXLINE+1, never NULL
+      93             : )
+      94             : {
+      95             : 
+      96             :     // check inputs
+      97             :     ASSERT (buf != NULL) ;
+      98             : 
+      99             :     // check if comment line
+     100     4061578 :     if (buf [0] == '%')
+     101             :     {
+     102             :         // line is a comment
+     103        5256 :         return (true) ;
+     104             :     }
+     105             : 
+     106             :     // check if blank line
+     107     4056352 :     for (int k = 0 ; k <= MAXLINE ; k++)
+     108             :     {
+     109     4056352 :         int c = buf [k] ;
+     110     4056352 :         if (c == '\0')
+     111             :         {
+     112             :             // end of line
+     113          30 :             break ;
+     114             :         }
+     115     4056322 :         if (!isspace (c))
+     116             :         {
+     117             :             // non-space character; this is not an error
+     118     4056292 :             return (false) ;
+     119             :         }
+     120             :     }
+     121             : 
+     122             :     // line is blank
+     123          30 :     return (true) ;
+     124             : }
+     125             : 
+     126             : //------------------------------------------------------------------------------
+     127             : // read_double
+     128             : //------------------------------------------------------------------------------
+     129             : 
+     130             : // Read a single double value from a string.  The string may be any string
+     131             : // recognized by sscanf, or inf, -inf, +inf, or nan.  The token infinity is
+     132             : // also OK instead of inf (only the first 3 letters of inf* or nan* are
+     133             : // significant, and the rest are ignored).
+     134             : 
+     135     3157602 : static inline bool read_double      // true if successful, false if failure
+     136             : (
+     137             :     char *p,        // string containing the value
+     138             :     double *rval    // value to read in
+     139             : )
+     140             : {
+     141     3157602 :     while (*p && isspace (*p)) p++ ;   // skip any spaces
+     142             : 
+     143     3157602 :     if (MATCH (p, "inf", 3) || MATCH (p, "+inf", 4))
+     144             :     {
+     145          96 :         (*rval) = INFINITY ;
+     146             :     }
+     147     3157506 :     else if (MATCH (p, "-inf", 4))
+     148             :     {
+     149          46 :         (*rval) = -INFINITY ;
+     150             :     }
+     151     3157460 :     else if (MATCH (p, "nan", 3))
+     152             :     {
+     153           4 :         (*rval) = NAN ;
+     154             :     }
+     155             :     else
+     156             :     {
+     157     3157456 :         if (sscanf (p, "%lg", rval) != 1)
+     158             :         {
+     159             :             // invalid file format, EOF, or other I/O error
+     160           1 :             return (false) ;
+     161             :         }
+     162             :     }
+     163     3157601 :     return (true) ;
+     164             : }
+     165             : 
+     166             : //------------------------------------------------------------------------------
+     167             : // read_entry: read a numerical value and typecast to the given type
+     168             : //------------------------------------------------------------------------------
+     169             : 
+     170     4054330 : static inline bool read_entry   // returns true if successful, false if failure
+     171             : (
+     172             :     char *p,        // string containing the value
+     173             :     GrB_Type type,  // type of value to read
+     174             :     bool structural,   // if true, then the value is 1
+     175             :     uint8_t *x      // value read in, a pointer to space of size of the type
+     176             : )
+     177             : {
+     178             : 
+     179     4054330 :     int64_t ival = 1 ;
+     180     4054330 :     double rval = 1, zval = 0 ;
+     181             : 
+     182     4054330 :     while (*p && isspace (*p)) p++ ;   // skip any spaces
+     183             : 
+     184     4054330 :     if (type == GrB_BOOL)
+     185             :     {
+     186      767170 :         if (!structural && sscanf (p, "%" SCNd64, &ival) != 1) return (false) ;
+     187      767170 :         if (ival < 0 || ival > 1)
+     188             :         {
+     189             :             // entry out of range
+     190           1 :             return (false) ;
+     191             :         }
+     192      767169 :         bool *result = (bool *) x ;
+     193      767169 :         result [0] = (bool) ival ;
+     194             :     }
+     195     3287160 :     else if (type == GrB_INT8)
+     196             :     {
+     197         511 :         if (!structural && sscanf (p, "%" SCNd64, &ival) != 1) return (false) ;
+     198         511 :         if (ival < INT8_MIN || ival > INT8_MAX)
+     199             :         {
+     200             :             // entry out of range
+     201           1 :             return (false) ;
+     202             :         }
+     203         510 :         int8_t *result = (int8_t *) x ;
+     204         510 :         result [0] = (int8_t) ival ;
+     205             :     }
+     206     3286649 :     else if (type == GrB_INT16)
+     207             :     {
+     208         523 :         if (!structural && sscanf (p, "%" SCNd64, &ival) != 1) return (false) ;
+     209         523 :         if (ival < INT16_MIN || ival > INT16_MAX)
+     210             :         {
+     211             :             // entry out of range
+     212           1 :             return (false) ;
+     213             :         }
+     214         522 :         int16_t *result = (int16_t *) x ;
+     215         522 :         result [0] = (int16_t) ival ;
+     216             :     }
+     217     3286126 :     else if (type == GrB_INT32)
+     218             :     {
+     219        1603 :         if (!structural && sscanf (p, "%" SCNd64, &ival) != 1) return (false) ;
+     220        1603 :         if (ival < INT32_MIN || ival > INT32_MAX)
+     221             :         {
+     222             :             // entry out of range
+     223           1 :             return (false) ;
+     224             :         }
+     225        1602 :         int32_t *result = (int32_t *) x ;
+     226        1602 :         result [0] = (int32_t) ival ;
+     227             :     }
+     228     3284523 :     else if (type == GrB_INT64)
+     229             :     {
+     230        3026 :         if (!structural && sscanf (p, "%" SCNd64, &ival) != 1) return (false) ;
+     231        3026 :         int64_t *result = (int64_t *) x ;
+     232        3026 :         result [0] = (int64_t) ival ;
+     233             :     }
+     234     3281497 :     else if (type == GrB_UINT8)
+     235             :     {
+     236         290 :         if (!structural && sscanf (p, "%" SCNd64, &ival) != 1) return (false) ;
+     237         290 :         if (ival < 0 || ival > UINT8_MAX)
+     238             :         {
+     239             :             // entry out of range
+     240           1 :             return (false) ;
+     241             :         }
+     242         289 :         uint8_t *result = (uint8_t *) x ;
+     243         289 :         result [0] = (uint8_t) ival ;
+     244             :     }
+     245     3281207 :     else if (type == GrB_UINT16)
+     246             :     {
+     247         290 :         if (!structural && sscanf (p, "%" SCNd64, &ival) != 1) return (false) ;
+     248         290 :         if (ival < 0 || ival > UINT16_MAX)
+     249             :         {
+     250             :             // entry out of range
+     251           1 :             return (false) ;
+     252             :         }
+     253         289 :         uint16_t *result = (uint16_t *) x ;
+     254         289 :         result [0] = (uint16_t) ival ;
+     255             :     }
+     256     3280917 :     else if (type == GrB_UINT32)
+     257             :     {
+     258         290 :         if (!structural && sscanf (p, "%" SCNd64, &ival) != 1) return (false) ;
+     259         290 :         if (ival < 0 || ival > UINT32_MAX)
+     260             :         {
+     261             :             // entry out of range
+     262           1 :             return (false) ;
+     263             :         }
+     264         289 :         uint32_t *result = (uint32_t *) x ;
+     265         289 :         result [0] = (uint32_t) ival ;
+     266             :     }
+     267     3280627 :     else if (type == GrB_UINT64)
+     268             :     {
+     269         312 :         uint64_t uval = 1 ;
+     270         312 :         if (!structural && sscanf (p, "%" SCNu64, &uval) != 1) return (false) ;
+     271         312 :         uint64_t *result = (uint64_t *) x ;
+     272         312 :         result [0] = (uint64_t) uval ;
+     273             :     }
+     274     3280315 :     else if (type == GrB_FP32)
+     275             :     {
+     276     1090459 :         if (!structural && !read_double (p, &rval)) return (false) ;
+     277     1090459 :         float *result = (float *) x ;
+     278     1090459 :         result [0] = (float) rval ;
+     279             :     }
+     280     2189856 :     else if (type == GrB_FP64)
+     281             :     {
+     282     2189856 :         if (!structural && !read_double (p, &rval)) return (false) ;
+     283     2189855 :         double *result = (double *) x ;
+     284     2189855 :         result [0] = rval ;
+     285             :     }
+     286             : #if 0
+     287             :     else if (type == GxB_FC32)
+     288             :     {
+     289             :         if (!structural && !read_double (p, &rval)) return (false) ;
+     290             :         while (*p && !isspace (*p)) p++ ;   // skip real part
+     291             :         if (!structural && !read_double (p, &zval)) return (false) ;
+     292             :         float *result = (float *) x ;
+     293             :         result [0] = (float) rval ;     // real part
+     294             :         result [1] = (float) zval ;     // imaginary part
+     295             :     }
+     296             :     else if (type == GxB_FC64)
+     297             :     {
+     298             :         if (!structural && !read_double (p, &rval)) return (false) ;
+     299             :         while (*p && !isspace (*p)) p++ ;   // skip real part
+     300             :         if (!structural && !read_double (p, &zval)) return (false) ;
+     301             :         double *result = (double *) x ;
+     302             :         result [0] = rval ;     // real part
+     303             :         result [1] = zval ;     // imaginary part
+     304             :     }
+     305             : #endif
+     306             : 
+     307     4054322 :     return (true) ;
+     308             : }
+     309             : 
+     310             : //------------------------------------------------------------------------------
+     311             : // negate_scalar: negate a scalar value
+     312             : //------------------------------------------------------------------------------
+     313             : 
+     314             : // negate the scalar x.  Do nothing for bool or uint*.
+     315             : 
+     316        1340 : static inline void negate_scalar
+     317             : (
+     318             :     GrB_Type type,
+     319             :     uint8_t *x
+     320             : )
+     321             : {
+     322             : 
+     323        1340 :     if (type == GrB_INT8)
+     324             :     {
+     325         210 :         int8_t *value = (int8_t *) x ;
+     326         210 :         (*value) = - (*value) ;
+     327             :     }
+     328        1130 :     else if (type == GrB_INT16)
+     329             :     {
+     330         210 :         int16_t *value = (int16_t *) x ;
+     331         210 :         (*value) = - (*value) ;
+     332             :     }
+     333         920 :     else if (type == GrB_INT32)
+     334             :     {
+     335         210 :         int32_t *value = (int32_t *) x ;
+     336         210 :         (*value) = - (*value) ;
+     337             :     }
+     338         710 :     else if (type == GrB_INT64)
+     339             :     {
+     340         210 :         int64_t *value = (int64_t *) x ;
+     341         210 :         (*value) = - (*value) ;
+     342             :     }
+     343         500 :     else if (type == GrB_FP32)
+     344             :     {
+     345         290 :         float *value = (float *) x ;
+     346         290 :         (*value) = - (*value) ;
+     347             :     }
+     348         210 :     else if (type == GrB_FP64)
+     349             :     {
+     350         210 :         double *value = (double *) x ;
+     351         210 :         (*value) = - (*value) ;
+     352             :     }
+     353             : #if 0
+     354             :     else if (type == GxB_FC32)
+     355             :     {
+     356             :         float complex *value = (float complex *) x ;
+     357             :         (*value) = - (*value) ;
+     358             :     }
+     359             :     else if (type == GxB_FC64)
+     360             :     {
+     361             :         double complex *value = (double complex *) x ;
+     362             :         (*value) = - (*value) ;
+     363             :     }
+     364             : #endif
+     365        1340 : }
+     366             : 
+     367             : //------------------------------------------------------------------------------
+     368             : // set_value
+     369             : //------------------------------------------------------------------------------
+     370             : 
+     371             : // Add the (i,j,x) triplet to the I,J,X arrays as the kth triplet, and
+     372             : // increment k.  No typecasting is done.
+     373             : 
+     374     6291344 : static inline void set_value
+     375             : (
+     376             :     size_t typesize,        // size of the numerical type, in bytes
+     377             :     GrB_Index i,
+     378             :     GrB_Index j,
+     379             :     uint8_t *x,             // scalar, an array of size at least typesize
+     380             :     GrB_Index *I,
+     381             :     GrB_Index *J,
+     382             :     uint8_t *X,
+     383             :     GrB_Index *k            // # of triplets
+     384             : )
+     385             : {
+     386     6291344 :     I [*k] = i ;
+     387     6291344 :     J [*k] = j ;
+     388     6291344 :     memcpy (X + ((*k) * typesize), x, typesize) ;
+     389     6291344 :     (*k)++ ;
+     390     6291344 : }
+     391             : 
+     392             : //------------------------------------------------------------------------------
+     393             : // LAGraph_MMRead
+     394             : //------------------------------------------------------------------------------
+     395             : 
+     396        1974 : int LAGraph_MMRead
+     397             : (
+     398             :     // output:
+     399             :     GrB_Matrix *A,  // handle of matrix to create
+     400             :     // input:
+     401             :     FILE *f,        // file to read from, already open
+     402             :     char *msg
+     403             : )
+     404             : {
+     405             : 
+     406             :     //--------------------------------------------------------------------------
+     407             :     // check inputs
+     408             :     //--------------------------------------------------------------------------
+     409             : 
+     410        1974 :     GrB_Index *I = NULL, *J = NULL ;
+     411        1974 :     uint8_t *X = NULL ;
+     412        1974 :     LG_CLEAR_MSG ;
+     413        1974 :     LG_ASSERT (A != NULL, GrB_NULL_POINTER) ;
+     414        1973 :     LG_ASSERT (f != NULL, GrB_NULL_POINTER) ;
+     415        1972 :     (*A) = NULL ;
+     416             : 
+     417             :     //--------------------------------------------------------------------------
+     418             :     // set the default properties
+     419             :     //--------------------------------------------------------------------------
+     420             : 
+     421        1972 :     MM_fmt_enum     MM_fmt     = MM_coordinate ;
+     422        1972 :     MM_type_enum    MM_type    = MM_real ;
+     423        1972 :     MM_storage_enum MM_storage = MM_general ;
+     424        1972 :     GrB_Type type = GrB_FP64 ;
+     425        1972 :     size_t typesize = sizeof (double) ;
+     426        1972 :     GrB_Index nrows = 0 ;
+     427        1972 :     GrB_Index ncols = 0 ;
+     428        1972 :     GrB_Index nvals = 0 ;
+     429             : 
+     430             :     //--------------------------------------------------------------------------
+     431             :     // read the Matrix Market header
+     432             :     //--------------------------------------------------------------------------
+     433             : 
+     434             :     // Read the header.  This consists of zero or more comment lines (blank, or
+     435             :     // starting with a "%" in the first column), followed by a single data line
+     436             :     // containing two or three numerical values.  The first line is normally:
+     437             :     //
+     438             :     //          %%MatrixMarket matrix <fmt> <type> <storage>
+     439             :     //
+     440             :     // but this is optional.  The 2nd line is also optional (the %%MatrixMarket
+     441             :     // line is required for this 2nd line to be recognized):
+     442             :     //
+     443             :     //          %%GraphBLAS type <Ctype>
+     444             :     //
+     445             :     // where the Ctype is one of: bool, int8_t, int16_t, int32_t, int64_t,
+     446             :     // uint8_t, uint16_t, uint32_t, uint64_t, float, or double.
+     447             :     //
+     448             :     // If the %%MatrixMarket line is not present, then the <fmt> <type> and
+     449             :     // <storage> are implicit.  If the first data line contains 3 items,
+     450             :     // then the implicit header is:
+     451             :     //
+     452             :     //          %%MatrixMarket matrix coordinate real general
+     453             :     //          %%GraphBLAS type double
+     454             :     //
+     455             :     // If the first data line contains 2 items (nrows ncols), then the implicit
+     456             :     // header is:
+     457             :     //
+     458             :     //          %%MatrixMarket matrix array real general
+     459             :     //          %%GraphBLAS type double
+     460             :     //
+     461             :     // The implicit header is an extension of the Matrix Market format.
+     462             : 
+     463             :     char buf [MAXLINE+1] ;
+     464             : 
+     465        1972 :     bool got_mm_header = false ;
+     466        1972 :     bool got_first_data_line = false ;
+     467             :     int64_t line ;
+     468             : 
+     469       10713 :     for (line = 1 ; get_line (f, buf) ; line++)
+     470             :     {
+     471             : 
+     472             :         //----------------------------------------------------------------------
+     473             :         // parse the line
+     474             :         //----------------------------------------------------------------------
+     475             : 
+     476       10713 :         if ((line == 1) && MATCH (buf, "%%matrixmarket", 14))
+     477        1956 :         {
+     478             : 
+     479             :             //------------------------------------------------------------------
+     480             :             // read a Matrix Market header
+     481             :             //------------------------------------------------------------------
+     482             : 
+     483             :             //  %%MatrixMarket matrix <fmt> <type> <storage>
+     484             :             //  if present, it must be the first line in the file.
+     485             : 
+     486        1964 :             got_mm_header = true ;
+     487        1964 :             char *p = buf + 14 ;
+     488             : 
+     489             :             //------------------------------------------------------------------
+     490             :             // get "matrix" token and discard it
+     491             :             //------------------------------------------------------------------
+     492             : 
+     493        3928 :             while (*p && isspace (*p)) p++ ;        // skip any leading spaces
+     494             : 
+     495        1964 :             if (!MATCH (p, "matrix", 6))
+     496             :             {
+     497             :                 // invalid Matrix Market object
+     498           1 :                 LG_ASSERT_MSG (false,
+     499             :                     LAGRAPH_IO_ERROR, "invalid MatrixMarket header"
+     500             :                     " ('matrix' token missing)") ;
+     501             :             }
+     502        1963 :             p += 6 ;                                // skip past token "matrix"
+     503             : 
+     504             :             //------------------------------------------------------------------
+     505             :             // get the fmt token
+     506             :             //------------------------------------------------------------------
+     507             : 
+     508        3926 :             while (*p && isspace (*p)) p++ ;        // skip any leading spaces
+     509             : 
+     510        1963 :             if (MATCH (p, "coordinate", 10))
+     511             :             {
+     512        1876 :                 MM_fmt = MM_coordinate ;
+     513        1876 :                 p += 10 ;
+     514             :             }
+     515          87 :             else if (MATCH (p, "array", 5))
+     516             :             {
+     517          86 :                 MM_fmt = MM_array ;
+     518          86 :                 p += 5 ;
+     519             :             }
+     520             :             else
+     521             :             {
+     522             :                 // invalid Matrix Market format
+     523           1 :                 LG_ASSERT_MSG (false,
+     524             :                     LAGRAPH_IO_ERROR, "invalid format in MatrixMarket header"
+     525             :                     " (format must be 'coordinate' or 'array')") ;
+     526             :             }
+     527             : 
+     528             :             //------------------------------------------------------------------
+     529             :             // get the Matrix Market type token
+     530             :             //------------------------------------------------------------------
+     531             : 
+     532        3924 :             while (*p && isspace (*p)) p++ ;        // skip any leading spaces
+     533             : 
+     534        1962 :             if (MATCH (p, "real", 4))
+     535             :             {
+     536         621 :                 MM_type = MM_real ;
+     537         621 :                 type = GrB_FP64 ;
+     538         621 :                 typesize = sizeof (double) ;
+     539         621 :                 p += 4 ;
+     540             :             }
+     541        1341 :             else if (MATCH (p, "integer", 7))
+     542             :             {
+     543         799 :                 MM_type = MM_integer ;
+     544         799 :                 type = GrB_INT64 ;
+     545         799 :                 typesize = sizeof (int64_t) ;
+     546         799 :                 p += 7 ;
+     547             :             }
+     548         542 :             else if (MATCH (p, "complex", 7))
+     549             :             {
+     550           1 :                 MM_type = MM_complex ;
+     551             : #if 0
+     552             :                 type = GxB_FC64 ;
+     553             :                 typesize = sizeof (GxB_FC64_t) ;
+     554             :                 p += 7 ;
+     555             : #endif
+     556           1 :                 LG_ASSERT_MSG (false,
+     557             :                 GrB_NOT_IMPLEMENTED, "complex types not supported") ;
+     558             :             }
+     559         541 :             else if (MATCH (p, "pattern", 7))
+     560             :             {
+     561         540 :                 MM_type = MM_pattern ;
+     562         540 :                 type = GrB_BOOL ;
+     563         540 :                 typesize = sizeof (bool) ;
+     564         540 :                 p += 7 ;
+     565             :             }
+     566             :             else
+     567             :             {
+     568             :                 // invalid Matrix Market type
+     569           1 :                 LG_ASSERT_MSG (false,
+     570             :                     LAGRAPH_IO_ERROR, "invalid MatrixMarket type") ;
+     571             :             }
+     572             : 
+     573             :             //------------------------------------------------------------------
+     574             :             // get the storage token
+     575             :             //------------------------------------------------------------------
+     576             : 
+     577        3920 :             while (*p && isspace (*p)) p++ ;        // skip any leading spaces
+     578             : 
+     579        1960 :             if (MATCH (p, "general", 7))
+     580             :             {
+     581        1170 :                 MM_storage = MM_general ;
+     582             :             }
+     583         790 :             else if (MATCH (p, "symmetric", 9))
+     584             :             {
+     585         616 :                 MM_storage = MM_symmetric ;
+     586             :             }
+     587         174 :             else if (MATCH (p, "skew-symmetric", 14))
+     588             :             {
+     589         171 :                 MM_storage = MM_skew_symmetric ;
+     590             :             }
+     591           3 :             else if (MATCH (p, "hermitian", 9))
+     592             :             {
+     593           2 :                 MM_storage = MM_hermitian ;
+     594             :             }
+     595             :             else
+     596             :             {
+     597             :                 // invalid Matrix Market storage
+     598           1 :                 LG_ASSERT_MSG (false,
+     599             :                     LAGRAPH_IO_ERROR, "invalid MatrixMarket storage") ;
+     600             :             }
+     601             : 
+     602             :             //------------------------------------------------------------------
+     603             :             // ensure the combinations are valid
+     604             :             //------------------------------------------------------------------
+     605             : 
+     606        1959 :             if (MM_type == MM_pattern)
+     607             :             {
+     608             :                 // (coodinate) x (pattern) x (general or symmetric)
+     609         540 :                 LG_ASSERT_MSG (
+     610             :                     (MM_fmt == MM_coordinate &&
+     611             :                     (MM_storage == MM_general || MM_storage == MM_symmetric)),
+     612             :                     LAGRAPH_IO_ERROR,
+     613             :                     "invalid MatrixMarket pattern combination") ;
+     614             :             }
+     615             : 
+     616        1957 :             if (MM_storage == MM_hermitian)
+     617             :             {
+     618             :                 // (coordinate or array) x (complex) x (Hermitian)
+     619           1 :                 LG_ASSERT_MSG (MM_type == MM_complex,
+     620             :                     LAGRAPH_IO_ERROR,
+     621             :                     "invalid MatrixMarket complex combination") ;
+     622             :             }
+     623             : 
+     624             :         }
+     625        8749 :         else if (got_mm_header && MATCH (buf, "%%graphblas", 11))
+     626        1498 :         {
+     627             : 
+     628             :             //------------------------------------------------------------------
+     629             :             // %%GraphBLAS structured comment
+     630             :             //------------------------------------------------------------------
+     631             : 
+     632        1548 :             char *p = buf + 11 ;
+     633        3096 :             while (*p && isspace (*p)) p++ ;        // skip any leading spaces
+     634             : 
+     635        1548 :             if (MATCH (p, "type", 4) && !got_first_data_line)
+     636             :             {
+     637             : 
+     638             :                 //--------------------------------------------------------------
+     639             :                 // %%GraphBLAS type <Ctype>
+     640             :                 //--------------------------------------------------------------
+     641             : 
+     642             :                 // This must appear after the %%MatrixMarket header and before
+     643             :                 // the first data line.  Otherwise the %%GraphBLAS line is
+     644             :                 // treated as a pure comment.
+     645             : 
+     646        1502 :                 p += 4 ;
+     647        3004 :                 while (*p && isspace (*p)) p++ ;    // skip any leading spaces
+     648             : 
+     649             :                 // Ctype is one of: bool, int8_t, int16_t, int32_t, int64_t,
+     650             :                 // uint8_t, uint16_t, uint32_t, uint64_t, float, or double.
+     651             :                 // The complex types "float complex", or "double complex" are
+     652             :                 // not yet supported.
+     653             : 
+     654        1502 :                 if (MATCH (p, "bool", 4))
+     655             :                 {
+     656         519 :                     type = GrB_BOOL ;
+     657         519 :                     typesize = sizeof (bool) ;
+     658             :                 }
+     659         983 :                 else if (MATCH (p, "int8_t", 6))
+     660             :                 {
+     661          59 :                     type = GrB_INT8 ;
+     662          59 :                     typesize = sizeof (int8_t) ;
+     663             :                 }
+     664         924 :                 else if (MATCH (p, "int16_t", 7))
+     665             :                 {
+     666          60 :                     type = GrB_INT16 ;
+     667          60 :                     typesize = sizeof (int16_t) ;
+     668             :                 }
+     669         864 :                 else if (MATCH (p, "int32_t", 7))
+     670             :                 {
+     671         176 :                     type = GrB_INT32 ;
+     672         176 :                     typesize = sizeof (int32_t) ;
+     673             :                 }
+     674         688 :                 else if (MATCH (p, "int64_t", 7))
+     675             :                 {
+     676         160 :                     type = GrB_INT64 ;
+     677         160 :                     typesize = sizeof (int64_t) ;
+     678             :                 }
+     679         528 :                 else if (MATCH (p, "uint8_t", 7))
+     680             :                 {
+     681          32 :                     type = GrB_UINT8 ;
+     682          32 :                     typesize = sizeof (uint8_t) ;
+     683             :                 }
+     684         496 :                 else if (MATCH (p, "uint16_t", 8))
+     685             :                 {
+     686          31 :                     type = GrB_UINT16 ;
+     687          31 :                     typesize = sizeof (uint16_t) ;
+     688             :                 }
+     689         465 :                 else if (MATCH (p, "uint32_t", 8))
+     690             :                 {
+     691          31 :                     type = GrB_UINT32 ;
+     692          31 :                     typesize = sizeof (uint32_t) ;
+     693             :                 }
+     694         434 :                 else if (MATCH (p, "uint64_t", 8))
+     695             :                 {
+     696          32 :                     type = GrB_UINT64 ;
+     697          32 :                     typesize = sizeof (uint64_t) ;
+     698             :                 }
+     699         402 :                 else if (MATCH (p, "float complex", 13))
+     700             :                 {
+     701             : #if 0
+     702             :                     type = GxB_FC32 ;
+     703             :                     typesize = sizeof (GxB_FC32_t) ;
+     704             : #endif
+     705           1 :                     LG_ASSERT_MSG (false,
+     706             :                         GrB_NOT_IMPLEMENTED, "complex types not supported") ;
+     707             :                 }
+     708         401 :                 else if (MATCH (p, "double complex", 14))
+     709             :                 {
+     710             : #if 0
+     711             :                     type = GxB_FC64 ;
+     712             :                     typesize = sizeof (GxB_FC64_t) ;
+     713             : #endif
+     714           1 :                     LG_ASSERT_MSG (false,
+     715             :                         GrB_NOT_IMPLEMENTED, "complex types not supported") ;
+     716             :                 }
+     717         400 :                 else if (MATCH (p, "float", 5))
+     718             :                 {
+     719          96 :                     type = GrB_FP32 ;
+     720          96 :                     typesize = sizeof (float) ;
+     721             :                 }
+     722         304 :                 else if (MATCH (p, "double", 6))
+     723             :                 {
+     724         303 :                     type = GrB_FP64 ;
+     725         303 :                     typesize = sizeof (double) ;
+     726             :                 }
+     727             :                 else
+     728             :                 {
+     729             :                     // unknown type
+     730           1 :                     LG_ASSERT_MSG (false,
+     731             :                         LAGRAPH_IO_ERROR, "unknown type") ;
+     732             :                 }
+     733             : 
+     734        1499 :                 if (MM_storage == MM_skew_symmetric && (type == GrB_BOOL ||
+     735         160 :                     type == GrB_UINT8  || type == GrB_UINT16 ||
+     736         159 :                     type == GrB_UINT32 || type == GrB_UINT64))
+     737             :                 {
+     738             :                     // matrices with unsigned types cannot be skew-symmetric
+     739           1 :                     LG_ASSERT_MSG (false, LAGRAPH_IO_ERROR,
+     740             :                         "skew-symmetric matrices cannot have an unsigned type");
+     741             :                 }
+     742             :             }
+     743             :             else
+     744             :             {
+     745             :                 // %%GraphBLAS line but no "type" as the 2nd token; ignore it
+     746          46 :                 continue ;
+     747             :             }
+     748             : 
+     749             :         }
+     750        7201 :         else if (is_blank_line (buf))
+     751             :         {
+     752             : 
+     753             :             // -----------------------------------------------------------------
+     754             :             // blank line or comment line
+     755             :             // -----------------------------------------------------------------
+     756             : 
+     757        5241 :             continue ;
+     758             : 
+     759             :         }
+     760             :         else
+     761             :         {
+     762             : 
+     763             :             // -----------------------------------------------------------------
+     764             :             // read the first data line
+     765             :             // -----------------------------------------------------------------
+     766             : 
+     767             :             // format: [nrows ncols nvals] or just [nrows ncols]
+     768             : 
+     769        1960 :             got_first_data_line = true ;
+     770        1960 :             int nitems = sscanf (buf, "%" SCNu64 " %" SCNu64 " %" SCNu64,
+     771             :                 &nrows, &ncols, &nvals) ;
+     772             : 
+     773        1960 :             if (nitems == 2)
+     774             :             {
+     775             :                 // a dense matrix
+     776          86 :                 if (!got_mm_header)
+     777             :                 {
+     778             :                     // if no header, treat it as if it were
+     779             :                     // %%MatrixMarket matrix array real general
+     780           4 :                     MM_fmt = MM_array ;
+     781           4 :                     MM_type = MM_real ;
+     782           4 :                     MM_storage = MM_general ;
+     783           4 :                     type = GrB_FP64 ;
+     784           4 :                     typesize = sizeof (double) ;
+     785             :                 }
+     786          86 :                 if (MM_storage == MM_general)
+     787             :                 {
+     788             :                     // dense general matrix
+     789          54 :                     nvals = nrows * ncols ;
+     790             :                 }
+     791             :                 else
+     792             :                 {
+     793             :                     // dense symmetric, skew-symmetric, or hermitian matrix
+     794          32 :                     nvals = nrows + ((nrows * nrows - nrows) / 2) ;
+     795             :                 }
+     796             :             }
+     797        1874 :             else if (nitems == 3)
+     798             :             {
+     799             :                 // a sparse matrix
+     800        1873 :                 if (!got_mm_header)
+     801             :                 {
+     802             :                     // if no header, treat it as if it were
+     803             :                     // %%MatrixMarket matrix coordinate real general
+     804           4 :                     MM_fmt = MM_coordinate ;
+     805           4 :                     MM_type = MM_real ;
+     806           4 :                     MM_storage = MM_general ;
+     807           4 :                     type = GrB_FP64 ;
+     808           4 :                     typesize = sizeof (double) ;
+     809             :                 }
+     810             :             }
+     811             :             else
+     812             :             {
+     813             :                 // wrong number of items in first data line
+     814           1 :                 LG_ASSERT_MSGF (false,
+     815             :                     LAGRAPH_IO_ERROR, "invalid 1st data line"
+     816             :                     " (line %" PRId64 " of input file)", line) ;
+     817             :             }
+     818             : 
+     819        1959 :             if (nrows != ncols)
+     820             :             {
+     821             :                 // a rectangular matrix must be in the general storage
+     822          90 :                 LG_ASSERT_MSG (MM_storage == MM_general,
+     823             :                     LAGRAPH_IO_ERROR, "invalid rectangular storage") ;
+     824             :             }
+     825             : 
+     826             :             //------------------------------------------------------------------
+     827             :             // header has been read in
+     828             :             //------------------------------------------------------------------
+     829             : 
+     830        1958 :             break ;
+     831             :         }
+     832             :     }
+     833             : 
+     834             :     //--------------------------------------------------------------------------
+     835             :     // create the matrix
+     836             :     //--------------------------------------------------------------------------
+     837             : 
+     838        1958 :     GRB_TRY (GrB_Matrix_new (A, type, nrows, ncols)) ;
+     839             : 
+     840             :     //--------------------------------------------------------------------------
+     841             :     // quick return for empty matrix
+     842             :     //--------------------------------------------------------------------------
+     843             : 
+     844        1806 :     if (nrows == 0 || ncols == 0 || nvals == 0)
+     845             :     {
+     846             :         // success: return an empty matrix.  This is not an error.
+     847          11 :         return (GrB_SUCCESS) ;
+     848             :     }
+     849             : 
+     850             :     //--------------------------------------------------------------------------
+     851             :     // allocate space for the triplets
+     852             :     //--------------------------------------------------------------------------
+     853             : 
+     854        1795 :     GrB_Index nvals3 = ((MM_storage == MM_general) ? 1 : 2) * (nvals + 1) ;
+     855        1795 :     LG_TRY (LAGraph_Malloc ((void **) &I, nvals3, sizeof (GrB_Index), msg)) ;
+     856        1745 :     LG_TRY (LAGraph_Malloc ((void **) &J, nvals3, sizeof (GrB_Index), msg)) ;
+     857        1695 :     LG_TRY (LAGraph_Malloc ((void **) &X, nvals3, typesize, msg)) ;
+     858             : 
+     859             :     //--------------------------------------------------------------------------
+     860             :     // read in the triplets
+     861             :     //--------------------------------------------------------------------------
+     862             : 
+     863        1645 :     GrB_Index i = -1, j = 0 ;
+     864        1645 :     GrB_Index nvals2 = 0 ;
+     865     4055967 :     for (int64_t k = 0 ; k < nvals ; k++)
+     866             :     {
+     867             : 
+     868             :         //----------------------------------------------------------------------
+     869             :         // get the next triplet, skipping blank lines and comment lines
+     870             :         //----------------------------------------------------------------------
+     871             : 
+     872             :         uint8_t x [MAXLINE] ;       // scalar value
+     873             : 
+     874             :         while (true)
+     875          45 :         {
+     876             : 
+     877             :             //------------------------------------------------------------------
+     878             :             // read the file until finding the next triplet
+     879             :             //------------------------------------------------------------------
+     880             : 
+     881     4054378 :             bool ok = get_line (f, buf) ;
+     882     4054378 :             line++ ;
+     883     4054388 :             LG_ASSERT_MSG (ok, LAGRAPH_IO_ERROR, "premature EOF") ;
+     884     4054377 :             if (is_blank_line (buf))
+     885             :             {
+     886             :                 // blank line or comment
+     887          45 :                 continue ;
+     888             :             }
+     889             : 
+     890             :             //------------------------------------------------------------------
+     891             :             // get the row and column index
+     892             :             //------------------------------------------------------------------
+     893             : 
+     894     4054332 :             char *p = buf ;
+     895     4054332 :             if (MM_fmt == MM_array)
+     896             :             {
+     897             :                 // array format, column major order
+     898         977 :                 i++ ;
+     899         977 :                 if (i == nrows)
+     900             :                 {
+     901         152 :                     j++ ;
+     902         152 :                     if (MM_storage == MM_general)
+     903             :                     {
+     904             :                         // dense matrix in column major order
+     905          74 :                         i = 0 ;
+     906             :                     }
+     907             :                     else
+     908             :                     {
+     909             :                         // dense matrix in column major order, only the lower
+     910             :                         // triangular form is present, including the diagonal
+     911          78 :                         i = j ;
+     912             :                     }
+     913             :                 }
+     914             :             }
+     915             :             else
+     916             :             {
+     917             :                 // coordinate format; read the row index and column index
+     918     4053355 :                 int inputs = sscanf (p, "%" SCNu64 " %" SCNu64, &i, &j) ;
+     919     4053355 :                 LG_ASSERT_MSGF (inputs == 2, LAGRAPH_IO_ERROR,
+     920             :                     "line %" PRId64 " of input file: indices invalid", line) ;
+     921             :                 // check the indices (they are 1-based in the MM file format)
+     922     4053354 :                 LG_ASSERT_MSGF (i >= 1 && i <= nrows, GrB_INDEX_OUT_OF_BOUNDS,
+     923             :                     "line %" PRId64 " of input file: row index %" PRIu64
+     924             :                     " out of range (must be in range 1 to %" PRIu64")",
+     925             :                     line, i, nrows) ;
+     926     4053354 :                 LG_ASSERT_MSGF (j >= 1 && j <= ncols, GrB_INDEX_OUT_OF_BOUNDS,
+     927             :                     "line %" PRId64 " of input file: column index %" PRIu64
+     928             :                     " out of range (must be in range 1 to %" PRIu64")",
+     929             :                     line, j, ncols) ;
+     930             :                 // convert from 1-based to 0-based.
+     931     4053353 :                 i-- ;
+     932     4053353 :                 j-- ;
+     933             :                 // advance p to the 3rd token to get the value of the entry
+     934     4053353 :                 while (*p &&  isspace (*p)) p++ ;   // skip any leading spaces
+     935    17619616 :                 while (*p && !isspace (*p)) p++ ;   // skip the row index
+     936     8106706 :                 while (*p &&  isspace (*p)) p++ ;   // skip any spaces
+     937    17350928 :                 while (*p && !isspace (*p)) p++ ;   // skip the column index
+     938             :             }
+     939             : 
+     940             :             //------------------------------------------------------------------
+     941             :             // read the value of the entry
+     942             :             //------------------------------------------------------------------
+     943             : 
+     944     8155058 :             while (*p && isspace (*p)) p++ ;        // skip any spaces
+     945             : 
+     946     4054330 :             ok = read_entry (p, type, MM_type == MM_pattern, x) ;
+     947     4054330 :             LG_ASSERT_MSGF (ok, LAGRAPH_IO_ERROR, "entry value invalid on line"
+     948             :                 " %" PRId64 " of input file", line) ;
+     949             : 
+     950             :             //------------------------------------------------------------------
+     951             :             // set the value in the matrix
+     952             :             //------------------------------------------------------------------
+     953             : 
+     954     4054322 :             set_value (typesize, i, j, x, I, J, X, &nvals2) ;
+     955             : 
+     956             :             //------------------------------------------------------------------
+     957             :             // also set the A(j,i) entry, if symmetric
+     958             :             //------------------------------------------------------------------
+     959             : 
+     960     4054322 :             if (i != j && MM_storage != MM_general)
+     961             :             {
+     962     2237022 :                 if (MM_storage == MM_symmetric)
+     963             :                 {
+     964     2235682 :                     set_value (typesize, j, i, x, I, J, X, &nvals2) ;
+     965             :                 }
+     966        1340 :                 else if (MM_storage == MM_skew_symmetric)
+     967             :                 {
+     968        1340 :                     negate_scalar (type, x) ;
+     969        1340 :                     set_value (typesize, j, i, x, I, J, X, &nvals2) ;
+     970             :                 }
+     971             :                 #if 0
+     972             :                 else if (MM_storage == MM_hermitian)
+     973             :                 {
+     974             :                     double complex *value = (double complex *) x ;
+     975             :                     (*value) = conj (*value) ;
+     976             :                     set_value (typesize, j, i, x, I, J, X, &nvals2) ;
+     977             :                 }
+     978             :                 #endif
+     979             :             }
+     980             : 
+     981             :             // one more entry has been read in
+     982     4054322 :             break ;
+     983             :         }
+     984             :     }
+     985             : 
+     986             :     //--------------------------------------------------------------------------
+     987             :     // build the final matrix
+     988             :     //--------------------------------------------------------------------------
+     989             : 
+     990        1634 :     if (type == GrB_BOOL)
+     991             :     {
+     992         528 :         GRB_TRY (GrB_Matrix_build_BOOL (*A, I, J, (bool *) X, nvals2, NULL)) ;
+     993             :     }
+     994        1106 :     else if (type == GrB_INT8)
+     995             :     {
+     996          46 :         GRB_TRY (GrB_Matrix_build_INT8 (*A, I, J, (int8_t *) X, nvals2, NULL)) ;
+     997             :     }
+     998        1060 :     else if (type == GrB_INT16)
+     999             :     {
+    1000          47 :         GRB_TRY (GrB_Matrix_build_INT16 (*A, I, J, (int16_t *) X, nvals2, NULL)) ;
+    1001             :     }
+    1002        1013 :     else if (type == GrB_INT32)
+    1003             :     {
+    1004         137 :         GRB_TRY (GrB_Matrix_build_INT32 (*A, I, J, (int32_t *) X, nvals2, NULL)) ;
+    1005             :     }
+    1006         876 :     else if (type == GrB_INT64)
+    1007             :     {
+    1008         232 :         GRB_TRY (GrB_Matrix_build_INT64 (*A, I, J, (int64_t *) X, nvals2, NULL)) ;
+    1009             :     }
+    1010         644 :     else if (type == GrB_UINT8)
+    1011             :     {
+    1012          24 :         GRB_TRY (GrB_Matrix_build_UINT8 (*A, I, J, (uint8_t *) X, nvals2, NULL)) ;
+    1013             :     }
+    1014         620 :     else if (type == GrB_UINT16)
+    1015             :     {
+    1016          24 :         GRB_TRY (GrB_Matrix_build_UINT16 (*A, I, J, (uint16_t *) X, nvals2, NULL)) ;
+    1017             :     }
+    1018         596 :     else if (type == GrB_UINT32)
+    1019             :     {
+    1020          24 :         GRB_TRY (GrB_Matrix_build_UINT32 (*A, I, J, (uint32_t *) X, nvals2, NULL)) ;
+    1021             :     }
+    1022         572 :     else if (type == GrB_UINT64)
+    1023             :     {
+    1024          26 :         GRB_TRY (GrB_Matrix_build_UINT64 (*A, I, J, (uint64_t *) X, nvals2, NULL)) ;
+    1025             :     }
+    1026         546 :     else if (type == GrB_FP32)
+    1027             :     {
+    1028          84 :         GRB_TRY (GrB_Matrix_build_FP32 (*A, I, J, (float *) X, nvals2, NULL)) ;
+    1029             :     }
+    1030         462 :     else if (type == GrB_FP64)
+    1031             :     {
+    1032         462 :         GRB_TRY (GrB_Matrix_build_FP64 (*A, I, J, (double *) X, nvals2, NULL)) ;
+    1033             :     }
+    1034             : #if 0
+    1035             :     else if (type == GxB_FC32)
+    1036             :     {
+    1037             :         GRB_TRY (GxB_Matrix_build_FC32 (*A, I, J, (GxB_FC32_t *) X, nvals2, NULL)) ;
+    1038             :     }
+    1039             :     else if (type == GxB_FC64)
+    1040             :     {
+    1041             :         GRB_TRY (GxB_Matrix_build_FC64 (*A, I, J, (GxB_FC64_t *) X, nvals2, NULL)) ;
+    1042             :     }
+    1043             : #endif
+    1044             : 
+    1045             :     //--------------------------------------------------------------------------
+    1046             :     // free workspace and return result
+    1047             :     //--------------------------------------------------------------------------
+    1048             : 
+    1049        1247 :     LG_FREE_WORK ;
+    1050        1247 :     return (GrB_SUCCESS) ;
+    1051             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_MMWrite.c.func-sort-c.html b/src/utility/LAGraph_MMWrite.c.func-sort-c.html new file mode 100644 index 0000000000..e49d474520 --- /dev/null +++ b/src/utility/LAGraph_MMWrite.c.func-sort-c.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_MMWrite.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_MMWrite.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:166166100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_MMWrite1329
print_double120798
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_MMWrite.c.func.html b/src/utility/LAGraph_MMWrite.c.func.html new file mode 100644 index 0000000000..a451a51a76 --- /dev/null +++ b/src/utility/LAGraph_MMWrite.c.func.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_MMWrite.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_MMWrite.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:166166100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_MMWrite1329
print_double120798
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_MMWrite.c.gcov.html b/src/utility/LAGraph_MMWrite.c.gcov.html new file mode 100644 index 0000000000..9bf1d860bb --- /dev/null +++ b/src/utility/LAGraph_MMWrite.c.gcov.html @@ -0,0 +1,649 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_MMWrite.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_MMWrite.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:166166100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_MMWrite:  write a matrix to a Matrix Market file
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // LAGraph_MMWrite:  write a matrix to a Matrix Market file.
+      19             : 
+      20             : // Writes a matrix to a file in the Matrix Market format.  See LAGraph_MMRead
+      21             : // for a description of the format.
+      22             : 
+      23             : // The Matrix Market format is described at:
+      24             : // https://math.nist.gov/MatrixMarket/formats.html
+      25             : 
+      26             : // Parts of this code are from SuiteSparse/CHOLMOD/Check/cholmod_write.c, and
+      27             : // are used here by permission of the author of CHOLMOD/Check (T. A. Davis).
+      28             : 
+      29             : #include "LG_internal.h"
+      30             : 
+      31             : #undef  LG_FREE_WORK
+      32             : #define LG_FREE_WORK                    \
+      33             : {                                       \
+      34             :     LAGraph_Free ((void **) &I, NULL) ; \
+      35             :     LAGraph_Free ((void **) &J, NULL) ; \
+      36             :     LAGraph_Free ((void **) &K, NULL) ; \
+      37             :     LAGraph_Free ((void **) &X, NULL) ; \
+      38             :     GrB_free (&AT) ;                    \
+      39             :     GrB_free (&M) ;                     \
+      40             :     GrB_free (&C) ;                     \
+      41             : }
+      42             : 
+      43             : #undef  LG_FREE_ALL
+      44             : #define LG_FREE_ALL LG_FREE_WORK
+      45             : 
+      46             : //------------------------------------------------------------------------------
+      47             : // print_double
+      48             : //------------------------------------------------------------------------------
+      49             : 
+      50             : // Print a double value to the file, using the shortest format that ensures the
+      51             : // value is written precisely.  Returns true if successful, false if an I/O
+      52             : // error occurred.
+      53             : 
+      54      120798 : static bool print_double
+      55             : (
+      56             :     FILE *f,        // file to print to
+      57             :     double x        // value to print
+      58             : )
+      59             : {
+      60             : 
+      61             :     char s [MAXLINE], *p ;
+      62      120798 :     int64_t i, dest = 0, src = 0 ;
+      63             :     int width, ok ;
+      64             : 
+      65             :     //--------------------------------------------------------------------------
+      66             :     // handle Inf and NaN
+      67             :     //--------------------------------------------------------------------------
+      68             : 
+      69      120798 :     if (isnan (x))
+      70             :     {
+      71           1 :         return (fprintf (f, "nan") > 0) ;
+      72             :     }
+      73      120797 :     if (isinf (x))
+      74             :     {
+      75          12 :         return (fprintf (f, (x < 0) ? "-inf" : "inf") > 0) ;
+      76             :     }
+      77             : 
+      78             :     //--------------------------------------------------------------------------
+      79             :     // find the smallest acceptable precision
+      80             :     //--------------------------------------------------------------------------
+      81             : 
+      82      869437 :     for (width = 6 ; width < 20 ; width++)
+      83             :     {
+      84             :         double y ;
+      85      869437 :         sprintf (s, "%.*g", width, x) ;
+      86      869437 :         sscanf (s, "%lg", &y) ;
+      87      869437 :         if (x == y) break ;
+      88             :     }
+      89             : 
+      90             :     //--------------------------------------------------------------------------
+      91             :     // shorten the string
+      92             :     //--------------------------------------------------------------------------
+      93             : 
+      94             :     // change "e+0" to "e", change "e+" to "e", and change "e-0" to "e-"
+      95     1774378 :     for (i = 0 ; i < MAXLINE && s [i] != '\0' ; i++)
+      96             :     {
+      97     1671099 :         if (s [i] == 'e')
+      98             :         {
+      99       17506 :             if (s [i+1] == '+')
+     100             :             {
+     101        3532 :                 dest = i+1 ;
+     102        3532 :                 if (s [i+2] == '0')
+     103             :                 {
+     104             :                     // delete characters s[i+1] and s[i+2]
+     105        3324 :                     src = i+3 ;
+     106             :                 }
+     107             :                 else
+     108             :                 {
+     109             :                     // delete characters s[i+1]
+     110         208 :                     src = i+2 ;
+     111             :                 }
+     112             :             }
+     113       13974 :             else if (s [i+1] == '-')
+     114             :             {
+     115       13974 :                 dest = i+2 ;
+     116       13974 :                 if (s [i+2] == '0')
+     117             :                 {
+     118             :                     // delete character s[i+2]
+     119       12258 :                     src = i+3 ;
+     120             :                 }
+     121             :                 else
+     122             :                 {
+     123             :                     // no change
+     124        1716 :                     break ;
+     125             :                 }
+     126             :             }
+     127       31788 :             while (s [src] != '\0')
+     128             :             {
+     129       15998 :                 s [dest++] = s [src++] ;
+     130             :             }
+     131       15790 :             s [dest] = '\0' ;
+     132       15790 :             break ;
+     133             :         }
+     134             :     }
+     135             : 
+     136             :     // delete the leading "0" if present and not necessary
+     137      120785 :     p = s ;
+     138      120785 :     s [MAXLINE-1] = '\0' ;
+     139      120785 :     i = strlen (s) ;
+     140      120785 :     if (i > 2 && s [0] == '0' && s [1] == '.')
+     141             :     {
+     142             :         // change "0.x" to ".x"
+     143        9359 :         p = s + 1 ;
+     144             :     }
+     145      111426 :     else if (i > 3 && s [0] == '-' && s [1] == '0' && s [2] == '.')
+     146             :     {
+     147             :         // change "-0.x" to "-.x"
+     148        4528 :         s [1] = '-' ;
+     149        4528 :         p = s + 1 ;
+     150             :     }
+     151             : 
+     152             : #if 0
+     153             :     // double-check
+     154             :     i = sscanf (p, "%lg", &z) ;
+     155             :     if (i != 1 || y != z)
+     156             :     {
+     157             :         // oops! something went wrong in the "e+0" edit, above.
+     158             :         // this "cannot" happen
+     159             :         sprintf (s, "%.*g", width, x) ;
+     160             :         p = s ;
+     161             :     }
+     162             : #endif
+     163             : 
+     164             :     //--------------------------------------------------------------------------
+     165             :     // print the value to the file
+     166             :     //--------------------------------------------------------------------------
+     167             : 
+     168      120785 :     return (fprintf (f, "%s", p) > 0) ;
+     169             : }
+     170             : 
+     171             : //------------------------------------------------------------------------------
+     172             : // LAGraph_MMWrite: write a matrix to a MatrixMarket file
+     173             : //------------------------------------------------------------------------------
+     174             : 
+     175        1329 : int LAGraph_MMWrite
+     176             : (
+     177             :     // input:
+     178             :     GrB_Matrix A,       // matrix to write to the file
+     179             :     FILE *f,            // file to write it to, must be already open
+     180             :     FILE *fcomments,    // optional file with extra comments, may be NULL
+     181             :     char *msg
+     182             : )
+     183             : {
+     184             : 
+     185             :     //--------------------------------------------------------------------------
+     186             :     // check inputs
+     187             :     //--------------------------------------------------------------------------
+     188             : 
+     189        1329 :     LG_CLEAR_MSG ;
+     190        1329 :     void *X = NULL ;
+     191        1329 :     GrB_Index *I = NULL, *J = NULL, *K = NULL ;
+     192        1329 :     GrB_Matrix M = NULL, AT = NULL, C = NULL ;
+     193        1329 :     LG_ASSERT (A != NULL, GrB_NULL_POINTER) ;
+     194        1328 :     LG_ASSERT (f != NULL, GrB_NULL_POINTER) ;
+     195             : 
+     196             :     //--------------------------------------------------------------------------
+     197             :     // determine the basic matrix properties
+     198             :     //--------------------------------------------------------------------------
+     199             : 
+     200             :     GrB_Index nrows, ncols, nvals ;
+     201        1328 :     GRB_TRY (GrB_Matrix_nrows (&nrows, A)) ;
+     202        1328 :     GRB_TRY (GrB_Matrix_ncols (&ncols, A)) ;
+     203        1328 :     GRB_TRY (GrB_Matrix_nvals (&nvals, A)) ;
+     204        1328 :     GrB_Index n = nrows ;
+     205             : 
+     206             :     //--------------------------------------------------------------------------
+     207             :     // determine if the matrix is dense
+     208             :     //--------------------------------------------------------------------------
+     209             : 
+     210        1328 :     MM_fmt_enum MM_fmt = MM_coordinate ;
+     211             : 
+     212             :     // guard against integer overflow
+     213        1328 :     if (((double) nrows * (double) ncols < (double) INT64_MAX) &&
+     214        1328 :         (nvals == nrows * ncols))
+     215             :     {
+     216          60 :         MM_fmt = MM_array ;
+     217             :     }
+     218             : 
+     219             :     //--------------------------------------------------------------------------
+     220             :     // determine the entry type
+     221             :     //--------------------------------------------------------------------------
+     222             : 
+     223             :     GrB_Type type ;
+     224             :     char atype_name [LAGRAPH_MAX_NAME_LEN] ;
+     225        1328 :     LG_TRY (LAGraph_Matrix_TypeName (atype_name, A, msg)) ;
+     226        1328 :     LG_TRY (LAGraph_TypeFromName (&type, atype_name, msg)) ;
+     227             : 
+     228        1328 :     MM_type_enum MM_type = MM_integer ;
+     229             : 
+     230        1328 :     if (type == GrB_BOOL   || type == GrB_INT8   || type == GrB_INT16  ||
+     231         889 :         type == GrB_INT32  || type == GrB_INT64  || type == GrB_UINT8  ||
+     232         513 :         type == GrB_UINT16 || type == GrB_UINT32 || type == GrB_UINT64)
+     233             :     {
+     234         881 :         MM_type = MM_integer ;
+     235             :     }
+     236         447 :     else if (type == GrB_FP32 || type == GrB_FP64)
+     237             :     {
+     238         446 :         MM_type = MM_real ;
+     239             :     }
+     240             :     #if 0
+     241             :     #if LAGRAPH_SUITESPARSE
+     242             :     else if (type == GxB_FC32 || type == GxB_FC64)
+     243             :     {
+     244             :         MM_type = MM_complex ;
+     245             :     }
+     246             :     #endif
+     247             :     #endif
+     248             :     else
+     249             :     {
+     250           1 :         LG_ASSERT_MSG (false, GrB_NOT_IMPLEMENTED, "type not supported") ;
+     251             :     }
+     252             : 
+     253             :     //--------------------------------------------------------------------------
+     254             :     // determine symmetry
+     255             :     //--------------------------------------------------------------------------
+     256             : 
+     257        1327 :     MM_storage_enum MM_storage = MM_general ;
+     258             : 
+     259        1327 :     if (nrows == ncols)
+     260             :     {
+     261             :         // AT = A'
+     262        1803 :         GRB_TRY (GrB_Matrix_new (&AT, type, n, n)) ;
+     263        1152 :         GRB_TRY (GrB_transpose (AT, NULL, NULL, A, NULL)) ;
+     264             : 
+     265             :         //----------------------------------------------------------------------
+     266             :         // check for symmetry
+     267             :         //----------------------------------------------------------------------
+     268             : 
+     269        1046 :         bool isequal = false ;
+     270        1046 :         LG_TRY (LAGraph_Matrix_IsEqual (&isequal, A, AT, msg)) ;
+     271         778 :         if (isequal)
+     272             :         {
+     273         237 :             MM_storage = MM_symmetric ;
+     274             :         }
+     275             : 
+     276             :         //----------------------------------------------------------------------
+     277             :         // check for skew-symmetry
+     278             :         //----------------------------------------------------------------------
+     279             : 
+     280             :         // for signed types only
+     281         778 :         if (MM_storage == MM_general)
+     282             :         {
+     283             :             // select the operator
+     284         541 :             GrB_UnaryOp op = NULL ;
+     285         541 :             if      (type == GrB_INT8 ) op = GrB_AINV_INT8  ;
+     286         502 :             else if (type == GrB_INT16) op = GrB_AINV_INT16 ;
+     287         463 :             else if (type == GrB_INT32) op = GrB_AINV_INT32 ;
+     288         388 :             else if (type == GrB_INT64) op = GrB_AINV_INT64 ;
+     289         288 :             else if (type == GrB_FP32 ) op = GrB_AINV_FP32  ;
+     290         249 :             else if (type == GrB_FP64 ) op = GrB_AINV_FP64  ;
+     291             :             #if 0
+     292             :             else if (type == GxB_FC32 ) op = GxB_AINV_FC32 ;
+     293             :             else if (type == GxB_FC64 ) op = GxB_AINV_FC64 ;
+     294             :             #endif
+     295         541 :             if (op != NULL)
+     296             :             {
+     297         444 :                 GRB_TRY (GrB_apply (AT, NULL, NULL, op, AT, NULL)) ;
+     298         443 :                 LG_TRY (LAGraph_Matrix_IsEqual (&isequal, A, AT, msg)) ;
+     299         308 :                 if (isequal)
+     300             :                 {
+     301         102 :                     MM_storage = MM_skew_symmetric ;
+     302             :                 }
+     303             :             }
+     304             :         }
+     305             : 
+     306             :         //----------------------------------------------------------------------
+     307             :         // check for Hermitian (not yet supported)
+     308             :         //----------------------------------------------------------------------
+     309             : 
+     310             :         #if 0
+     311             :         if (MM_type == MM_complex && MM_storage == MM_general)
+     312             :         {
+     313             :             LG_TRY (LAGraph_Matrix_IsEqualOp (&isequal, A, AT,
+     314             :                 LAGraph_HERMITIAN_ComplexFP64, msg)) ;
+     315             :             if (isequal)
+     316             :             {
+     317             :                 MM_storage = MM_hermitian ;
+     318             :             }
+     319             :         }
+     320             :         #endif
+     321             : 
+     322         642 :         GrB_free (&AT) ;
+     323             :     }
+     324             : 
+     325             :     //--------------------------------------------------------------------------
+     326             :     // determine if the matrix is structural-only
+     327             :     //--------------------------------------------------------------------------
+     328             : 
+     329         676 :     bool is_structural = false ;
+     330         676 :     if (! (MM_storage == MM_skew_symmetric || MM_storage == MM_hermitian))
+     331             :     {
+     332         574 :         if (type == GrB_BOOL)
+     333             :         {
+     334         165 :             GRB_TRY (GrB_reduce (&is_structural, NULL, GrB_LAND_MONOID_BOOL,
+     335             :                 A, NULL)) ;
+     336             :         }
+     337             :         else
+     338             :         {
+     339         409 :             GRB_TRY (GrB_Matrix_new (&C, GrB_BOOL, nrows, ncols)) ;
+     340         320 :             GrB_BinaryOp op = NULL ;
+     341         320 :             if      (type == GrB_INT8  ) op = GrB_EQ_INT8   ;
+     342         311 :             else if (type == GrB_INT16 ) op = GrB_EQ_INT16  ;
+     343         302 :             else if (type == GrB_INT32 ) op = GrB_EQ_INT32  ;
+     344         270 :             else if (type == GrB_INT64 ) op = GrB_EQ_INT64  ;
+     345         190 :             else if (type == GrB_UINT8 ) op = GrB_EQ_UINT8  ;
+     346         181 :             else if (type == GrB_UINT16) op = GrB_EQ_UINT16 ;
+     347         172 :             else if (type == GrB_UINT32) op = GrB_EQ_UINT32 ;
+     348         163 :             else if (type == GrB_UINT64) op = GrB_EQ_UINT64 ;
+     349         154 :             else if (type == GrB_FP32  ) op = GrB_EQ_FP32   ;
+     350         145 :             else if (type == GrB_FP64  ) op = GrB_EQ_FP64   ;
+     351             :             #if 0
+     352             :             else if (type == GxB_FC32  ) op = GrB_EQ_FC32 ;
+     353             :             else if (type == GxB_FC64  ) op = GrB_EQ_FC64 ;
+     354             :             #endif
+     355         320 :             GRB_TRY (GrB_apply (C, NULL, NULL, op, A, 1, NULL)) ;
+     356         257 :             GRB_TRY (GrB_reduce (&is_structural, NULL, GrB_LAND_MONOID_BOOL,
+     357             :                 C, NULL)) ;
+     358         257 :             GrB_free (&C) ;
+     359             :         }
+     360         422 :         if (is_structural)
+     361             :         {
+     362         207 :             MM_type = MM_pattern ;
+     363         207 :             MM_fmt = MM_coordinate ;
+     364             :         }
+     365             :     }
+     366             : 
+     367             :     //--------------------------------------------------------------------------
+     368             :     // write the Matrix Market header
+     369             :     //--------------------------------------------------------------------------
+     370             : 
+     371         524 :     FPRINTF (f, "%%%%MatrixMarket matrix") ;
+     372             : 
+     373         524 :     switch (MM_fmt)
+     374             :     {
+     375         496 :         default :
+     376         496 :         case MM_coordinate      : FPRINTF (f, " coordinate")        ; break ;
+     377          28 :         case MM_array           : FPRINTF (f, " array")             ; break ;
+     378             :     }
+     379             : 
+     380         524 :     switch (MM_type)
+     381             :     {
+     382         158 :         default :
+     383         158 :         case MM_real            : FPRINTF (f, " real")              ; break ;
+     384         159 :         case MM_integer         : FPRINTF (f, " integer")           ; break ;
+     385             : //      case MM_complex         : FPRINTF (f, " complex")           ; break ;
+     386         207 :         case MM_pattern         : FPRINTF (f, " pattern")           ; break ;
+     387             :     }
+     388             : 
+     389         524 :     switch (MM_storage)
+     390             :     {
+     391         215 :         default :
+     392         215 :         case MM_general         : FPRINTF (f, " general\n")         ; break ;
+     393         207 :         case MM_symmetric       : FPRINTF (f, " symmetric\n")       ; break ;
+     394         102 :         case MM_skew_symmetric  : FPRINTF (f, " skew-symmetric\n")  ; break ;
+     395             : //      case MM_hermitian       : FPRINTF (f, " Hermitian\n")       ; break ;
+     396             :     }
+     397             : 
+     398         524 :     FPRINTF (f, "%%%%GraphBLAS type ") ;
+     399         524 :     if      (type == GrB_BOOL  ) { FPRINTF (f, "bool\n")   ; }
+     400         359 :     else if (type == GrB_INT8  ) { FPRINTF (f, "int8_t\n")   ; }
+     401         335 :     else if (type == GrB_INT16 ) { FPRINTF (f, "int16_t\n")  ; }
+     402         311 :     else if (type == GrB_INT32 ) { FPRINTF (f, "int32_t\n")  ; }
+     403         270 :     else if (type == GrB_INT64 ) { FPRINTF (f, "int64_t\n")  ; }
+     404         186 :     else if (type == GrB_UINT8 ) { FPRINTF (f, "uint8_t\n")  ; }
+     405         179 :     else if (type == GrB_UINT16) { FPRINTF (f, "uint16_t\n") ; }
+     406         172 :     else if (type == GrB_UINT32) { FPRINTF (f, "uint32_t\n") ; }
+     407         165 :     else if (type == GrB_UINT64) { FPRINTF (f, "uint64_t\n") ; }
+     408         158 :     else if (type == GrB_FP32  ) { FPRINTF (f, "float\n")   ; }
+     409         134 :     else if (type == GrB_FP64  ) { FPRINTF (f, "double\n")   ; }
+     410             :     #if 0
+     411             :     else if (type == GxB_FC32  ) { FPRINTF (f, "float complex\n")  ; }
+     412             :     else if (type == GxB_FC64  ) { FPRINTF (f, "double complex\n") ; }
+     413             :     #endif
+     414             : 
+     415             : #if 0
+     416             :     if      (type == GrB_BOOL  ) { FPRINTF (f, "GrB_BOOL\n")   ; }
+     417             :     else if (type == GrB_INT8  ) { FPRINTF (f, "GrB_INT8\n")   ; }
+     418             :     else if (type == GrB_INT16 ) { FPRINTF (f, "GrB_INT16\n")  ; }
+     419             :     else if (type == GrB_INT32 ) { FPRINTF (f, "GrB_INT32\n")  ; }
+     420             :     else if (type == GrB_INT64 ) { FPRINTF (f, "GrB_INT64\n")  ; }
+     421             :     else if (type == GrB_UINT8 ) { FPRINTF (f, "GrB_UINT8\n")  ; }
+     422             :     else if (type == GrB_UINT16) { FPRINTF (f, "GrB_UINT16\n") ; }
+     423             :     else if (type == GrB_UINT32) { FPRINTF (f, "GrB_UINT32\n") ; }
+     424             :     else if (type == GrB_UINT64) { FPRINTF (f, "GrB_UINT64\n") ; }
+     425             :     else if (type == GrB_FP32  ) { FPRINTF (f, "GrB_FP32\n")   ; }
+     426             :     else if (type == GrB_FP64  ) { FPRINTF (f, "GrB_FP64\n")   ; }
+     427             :     #if 0
+     428             :     else if (type == GxB_FC32  ) { FPRINTF (f, "GxB_FC32\n")   ; }
+     429             :     else if (type == GxB_FC64  ) { FPRINTF (f, "GxB_FC64\n")   ; }
+     430             :     #endif
+     431             : #endif
+     432             : 
+     433             :     //--------------------------------------------------------------------------
+     434             :     // include any additional comments
+     435             :     //--------------------------------------------------------------------------
+     436             : 
+     437         524 :     if (fcomments != NULL)
+     438             :     {
+     439             :         char buffer [MAXLINE] ;
+     440          12 :         while (fgets (buffer, MAXLINE-1, fcomments) != NULL)
+     441             :         {
+     442           8 :             FPRINTF (f, "%%%s", buffer) ;
+     443             :         }
+     444             :     }
+     445             : 
+     446             :     //--------------------------------------------------------------------------
+     447             :     // print the first line
+     448             :     //--------------------------------------------------------------------------
+     449             : 
+     450         524 :     bool is_general = (MM_storage == MM_general) ;
+     451         524 :     GrB_Index nvals_to_print = nvals ;
+     452             : 
+     453         524 :     if (!is_general)
+     454             :     {
+     455             :         // count the entries on the diagonal
+     456         309 :         int64_t nself_edges = 0 ;
+     457         309 :         LG_TRY (LG_nself_edges (&nself_edges, A, msg)) ;
+     458             :         // nvals_to_print = # of entries in tril(A), including diagonal
+     459         130 :         nvals_to_print = nself_edges + (nvals - nself_edges) / 2 ;
+     460             :     }
+     461             : 
+     462         345 :     if (MM_fmt == MM_array)
+     463             :     {
+     464             :         // write `nrows ncols` if the array format is used
+     465          19 :         FPRINTF (f, "%" PRIu64 " %" PRIu64 "\n",
+     466             :             nrows, ncols) ;
+     467             :     }
+     468             :     else
+     469             :     {
+     470             :         // otherwise write `nrows ncols nvals` for the coordinate format
+     471         326 :         FPRINTF (f, "%" PRIu64 " %" PRIu64 " %" PRIu64 "\n",
+     472             :             nrows, ncols, nvals_to_print) ;
+     473             :     }
+     474             : 
+     475         345 :     if (nvals_to_print == 0)
+     476             :     {
+     477             :         // quick return if nothing more to do
+     478           2 :         LG_FREE_ALL ;
+     479           2 :         return (GrB_SUCCESS) ;
+     480             :     }
+     481             : 
+     482             :     //--------------------------------------------------------------------------
+     483             :     // extract and print tuples
+     484             :     //--------------------------------------------------------------------------
+     485             : 
+     486         343 :     LG_TRY (LAGraph_Malloc ((void **) &I, nvals, sizeof (GrB_Index), msg)) ;
+     487         293 :     LG_TRY (LAGraph_Malloc ((void **) &J, nvals, sizeof (GrB_Index), msg)) ;
+     488         243 :     LG_TRY (LAGraph_Malloc ((void **) &K, nvals, sizeof (GrB_Index), msg)) ;
+     489      329549 :     for (int64_t k = 0 ; k < nvals ; k++)
+     490             :     {
+     491      329356 :         K [k] = k ;
+     492             :     }
+     493             : 
+     494         193 :     GrB_Index nvals_printed = 0 ;
+     495         193 :     bool coord = (MM_fmt == MM_coordinate) ;
+     496             : 
+     497             :     #define WRITE_TUPLES(ctype,is_unsigned,is_signed,is_real,is_complex)    \
+     498             :     {                                                                       \
+     499             :         ctype *X = NULL ;                                                   \
+     500             :         LG_TRY (LAGraph_Malloc ((void **) &X, nvals, sizeof (ctype), msg)) ;\
+     501             :         GRB_TRY (GrB_Matrix_extractTuples (I, J, X, &nvals, A)) ;           \
+     502             :         LG_TRY (LG_msort3 ((int64_t *) J, (int64_t *) I,                    \
+     503             :             (int64_t *) K, nvals, msg)) ;                                   \
+     504             :         for (int64_t k = 0 ; k < nvals ; k++)                               \
+     505             :         {                                                                   \
+     506             :             /* convert the row and column index to 1-based */               \
+     507             :             GrB_Index i = I [k] + 1 ;                                       \
+     508             :             GrB_Index j = J [k] + 1 ;                                       \
+     509             :             ctype     x = X [K [k]] ;                                       \
+     510             :             if (is_general || i >= j)                                       \
+     511             :             {                                                               \
+     512             :                 /* print the row and column index of the tuple */           \
+     513             :                 if (coord) FPRINTF (f, "%" PRIu64 " %" PRIu64 " ", i, j) ;  \
+     514             :                 /* print the value of the tuple */                          \
+     515             :                 if (is_structural)                                          \
+     516             :                 {                                                           \
+     517             :                     /* print nothing */ ;                                   \
+     518             :                 }                                                           \
+     519             :                 else if (is_unsigned)                                       \
+     520             :                 {                                                           \
+     521             :                     FPRINTF (f, "%" PRIu64, (uint64_t) x) ;                 \
+     522             :                 }                                                           \
+     523             :                 else if (is_signed)                                         \
+     524             :                 {                                                           \
+     525             :                     FPRINTF (f, "%" PRId64, (int64_t) x) ;                  \
+     526             :                 }                                                           \
+     527             :                 else if (is_real)                                           \
+     528             :                 {                                                           \
+     529             :                     LG_ASSERT_MSG (print_double (f, (double) x),            \
+     530             :                         LAGRAPH_IO_ERROR, "Unable to write to file") ;      \
+     531             :                 }                                                           \
+     532             :             /*  else if (is_complex)                                 */     \
+     533             :             /*  {                                                    */     \
+     534             :             /*      LG_ASSERT_MSG (print_double (f, creal (x)),      */     \
+     535             :             /*          LAGRAPH_IO_ERROR,                            */     \
+     536             :             /*          "Unable to write to file") ;                 */     \
+     537             :             /*      FPRINTF (f, " ") ;                               */     \
+     538             :             /*      LG_ASSERT_MSG (print_double (f, cimag (x)),      */     \
+     539             :             /*          LAGRAPH_IO_ERROR,                            */     \
+     540             :             /*          "Unable to write to file") ;                 */     \
+     541             :             /*  }                                                    */     \
+     542             :                 FPRINTF (f, "\n") ;                                         \
+     543             :             }                                                               \
+     544             :             nvals_printed++ ;                                               \
+     545             :         }                                                                   \
+     546             :         LG_TRY (LAGraph_Free ((void **) &X, NULL)) ;                        \
+     547             :     }
+     548             : 
+     549       16069 :     if      (type == GrB_BOOL   ) WRITE_TUPLES (bool    , 1, 0, 0, 0)
+     550         200 :     else if (type == GrB_INT8   ) WRITE_TUPLES (int8_t  , 0, 1, 0, 0)
+     551         192 :     else if (type == GrB_INT16  ) WRITE_TUPLES (int16_t , 0, 1, 0, 0)
+     552         244 :     else if (type == GrB_INT32  ) WRITE_TUPLES (int32_t , 0, 1, 0, 0)
+     553         438 :     else if (type == GrB_INT64  ) WRITE_TUPLES (int64_t , 0, 1, 0, 0)
+     554          95 :     else if (type == GrB_UINT8  ) WRITE_TUPLES (uint8_t , 1, 0, 0, 0)
+     555          91 :     else if (type == GrB_UINT16 ) WRITE_TUPLES (uint16_t, 1, 0, 0, 0)
+     556          87 :     else if (type == GrB_UINT32 ) WRITE_TUPLES (uint32_t, 1, 0, 0, 0)
+     557          83 :     else if (type == GrB_UINT64 ) WRITE_TUPLES (uint64_t, 1, 0, 0, 0)
+     558         119 :     else if (type == GrB_FP32   ) WRITE_TUPLES (float   , 0, 0, 1, 0)
+     559      202769 :     else if (type == GrB_FP64   ) WRITE_TUPLES (double  , 0, 0, 1, 0)
+     560             :     #if 0
+     561             :     else if (type == GxB_FC32   ) WRITE_TUPLES (GxB_FC32_t, 0, 0, 0, 1) ;
+     562             :     else if (type == GxB_FC64   ) WRITE_TUPLES (GxB_FC64_t, 0, 0, 0, 1) ;
+     563             :     #endif
+     564             : 
+     565             :     ASSERT (nvals_to_print == nvals_printed) ;
+     566             : 
+     567             :     //--------------------------------------------------------------------------
+     568             :     // free workspace and return
+     569             :     //--------------------------------------------------------------------------
+     570             : 
+     571         105 :     LG_FREE_ALL ;
+     572         105 :     return (GrB_SUCCESS) ;
+     573             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Malloc.c.func-sort-c.html b/src/utility/LAGraph_Malloc.c.func-sort-c.html new file mode 100644 index 0000000000..7ea3ea36f3 --- /dev/null +++ b/src/utility/LAGraph_Malloc.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Malloc.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Malloc.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1010100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_Malloc26882
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Malloc.c.func.html b/src/utility/LAGraph_Malloc.c.func.html new file mode 100644 index 0000000000..2f644252dd --- /dev/null +++ b/src/utility/LAGraph_Malloc.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Malloc.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Malloc.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1010100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_Malloc26882
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Malloc.c.gcov.html b/src/utility/LAGraph_Malloc.c.gcov.html new file mode 100644 index 0000000000..7be473ac93 --- /dev/null +++ b/src/utility/LAGraph_Malloc.c.gcov.html @@ -0,0 +1,128 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Malloc.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Malloc.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1010100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_Malloc:  wrapper for malloc
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include "LG_internal.h"
+      19             : 
+      20       26882 : int LAGraph_Malloc
+      21             : (
+      22             :     // output:
+      23             :     void **p,               // pointer to allocated block of memory
+      24             :     // input:
+      25             :     size_t nitems,          // number of items
+      26             :     size_t size_of_item,    // size of each item
+      27             :     char *msg
+      28             : )
+      29             : {
+      30             :     // check inputs
+      31       26882 :     LG_CLEAR_MSG ;
+      32       26882 :     LG_ASSERT (p != NULL, GrB_NULL_POINTER) ;
+      33       26882 :     (*p) = NULL ;
+      34             : 
+      35             :     // make sure at least one item is allocated
+      36       26882 :     nitems = LAGRAPH_MAX (1, nitems) ;
+      37             : 
+      38             :     // make sure at least one byte is allocated
+      39       26882 :     size_of_item = LAGRAPH_MAX (1, size_of_item) ;
+      40             : 
+      41             :     // compute the size and check for integer overflow
+      42             :     size_t size ;
+      43       26882 :     if (!LG_Multiply_size_t (&size, nitems, size_of_item))
+      44             :     {
+      45             :         // overflow
+      46           1 :         return (GrB_OUT_OF_MEMORY) ;
+      47             :     }
+      48             : 
+      49             :     // malloc the space
+      50       26881 :     (*p) = LAGraph_Malloc_function (size) ;
+      51       26881 :     return (((*p) == NULL) ? GrB_OUT_OF_MEMORY : GrB_SUCCESS) ;
+      52             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Matrix_IsEqual.c.func-sort-c.html b/src/utility/LAGraph_Matrix_IsEqual.c.func-sort-c.html new file mode 100644 index 0000000000..8d073099c8 --- /dev/null +++ b/src/utility/LAGraph_Matrix_IsEqual.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Matrix_IsEqual.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Matrix_IsEqual.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:4848100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_Matrix_IsEqual3235
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Matrix_IsEqual.c.func.html b/src/utility/LAGraph_Matrix_IsEqual.c.func.html new file mode 100644 index 0000000000..b584202427 --- /dev/null +++ b/src/utility/LAGraph_Matrix_IsEqual.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Matrix_IsEqual.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Matrix_IsEqual.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:4848100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_Matrix_IsEqual3235
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Matrix_IsEqual.c.gcov.html b/src/utility/LAGraph_Matrix_IsEqual.c.gcov.html new file mode 100644 index 0000000000..65c7424144 --- /dev/null +++ b/src/utility/LAGraph_Matrix_IsEqual.c.gcov.html @@ -0,0 +1,237 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Matrix_IsEqual.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Matrix_IsEqual.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:4848100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_Matrix_IsEqual: check two matrices for exact equality
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // LAGraph_Matrix_IsEqual: check if two matrices are identically equal (same
+      19             : // size, type, structure, size, and values).
+      20             : 
+      21             : // If the two matrices are GrB_FP32, GrB_FP64, GxB_FC32, or GxB_FC64 and have
+      22             : // NaNs, then these functions will return false, since NaN == NaN is false.
+      23             : 
+      24             : #define LG_FREE_WORK GrB_free (&C) ;
+      25             : 
+      26             : #include "LG_internal.h"
+      27             : 
+      28        3235 : int LAGraph_Matrix_IsEqual
+      29             : (
+      30             :     // output:
+      31             :     bool *result,           // true if A == B, false if A != B or error
+      32             :     // input:
+      33             :     const GrB_Matrix A,
+      34             :     const GrB_Matrix B,
+      35             :     char *msg
+      36             : )
+      37             : {
+      38             : 
+      39             :     //--------------------------------------------------------------------------
+      40             :     // check inputs
+      41             :     //--------------------------------------------------------------------------
+      42             : 
+      43        3235 :     LG_CLEAR_MSG ;
+      44        3235 :     GrB_Matrix C = NULL ;
+      45        3235 :     LG_ASSERT (result != NULL, GrB_NULL_POINTER) ;
+      46             : 
+      47             :     //--------------------------------------------------------------------------
+      48             :     // check for NULL and aliased matrices
+      49             :     //--------------------------------------------------------------------------
+      50             : 
+      51        3230 :     if (A == NULL || B == NULL || A == B)
+      52             :     {
+      53             :         // two NULL matrices are identical, as are two aliased matrices
+      54          33 :         (*result) = (A == B) ;
+      55          33 :         return (GrB_SUCCESS) ;
+      56             :     }
+      57             : 
+      58             :     //--------------------------------------------------------------------------
+      59             :     // compare the type of A and B
+      60             :     //--------------------------------------------------------------------------
+      61             : 
+      62             :     char atype_name [LAGRAPH_MAX_NAME_LEN] ;
+      63             :     char btype_name [LAGRAPH_MAX_NAME_LEN] ;
+      64        3197 :     LG_TRY (LAGraph_Matrix_TypeName (atype_name, A, msg)) ;
+      65        3197 :     LG_TRY (LAGraph_Matrix_TypeName (btype_name, B, msg)) ;
+      66        3197 :     if (!MATCHNAME (atype_name, btype_name))
+      67             :     {
+      68             :         // types differ
+      69          12 :         (*result) = false ;
+      70          12 :         return (GrB_SUCCESS) ;
+      71             :     }
+      72             : 
+      73             :     //--------------------------------------------------------------------------
+      74             :     // compare the size of A and B
+      75             :     //--------------------------------------------------------------------------
+      76             : 
+      77             :     GrB_Index nrows1, ncols1, nrows2, ncols2 ;
+      78        3185 :     GRB_TRY (GrB_Matrix_nrows (&nrows1, A)) ;
+      79        3185 :     GRB_TRY (GrB_Matrix_nrows (&nrows2, B)) ;
+      80        3185 :     GRB_TRY (GrB_Matrix_ncols (&ncols1, A)) ;
+      81        3185 :     GRB_TRY (GrB_Matrix_ncols (&ncols2, B)) ;
+      82        3185 :     if (nrows1 != nrows2 || ncols1 != ncols2)
+      83             :     {
+      84             :         // dimensions differ
+      85           2 :         (*result) = false ;
+      86           2 :         return (GrB_SUCCESS) ;
+      87             :     }
+      88             : 
+      89             :     //--------------------------------------------------------------------------
+      90             :     // compare the # entries in A and B
+      91             :     //--------------------------------------------------------------------------
+      92             : 
+      93             :     GrB_Index nvals1, nvals2 ;
+      94        3183 :     GRB_TRY (GrB_Matrix_nvals (&nvals1, A)) ;
+      95        3183 :     GRB_TRY (GrB_Matrix_nvals (&nvals2, B)) ;
+      96        3183 :     if (nvals1 != nvals2)
+      97             :     {
+      98             :         // # of entries differ
+      99           2 :         (*result) = false ;
+     100           2 :         return (GrB_SUCCESS) ;
+     101             :     }
+     102             : 
+     103             :     //--------------------------------------------------------------------------
+     104             :     // get the GrB_EQ_type operator
+     105             :     //--------------------------------------------------------------------------
+     106             : 
+     107             :     GrB_Type type ;
+     108        3181 :     LG_TRY (LAGraph_TypeFromName (&type, atype_name, msg)) ;
+     109        3181 :     GrB_BinaryOp op = NULL ;
+     110        3181 :     if      (type == GrB_BOOL  ) op = GrB_EQ_BOOL   ;
+     111        2556 :     else if (type == GrB_INT8  ) op = GrB_EQ_INT8   ;
+     112        2425 :     else if (type == GrB_INT16 ) op = GrB_EQ_INT16  ;
+     113        2292 :     else if (type == GrB_INT32 ) op = GrB_EQ_INT32  ;
+     114        1979 :     else if (type == GrB_INT64 ) op = GrB_EQ_INT64  ;
+     115        1486 :     else if (type == GrB_UINT8 ) op = GrB_EQ_UINT8  ;
+     116        1442 :     else if (type == GrB_UINT16) op = GrB_EQ_UINT16 ;
+     117        1398 :     else if (type == GrB_UINT32) op = GrB_EQ_UINT32 ;
+     118        1240 :     else if (type == GrB_UINT64) op = GrB_EQ_UINT64 ;
+     119         938 :     else if (type == GrB_FP32  ) op = GrB_EQ_FP32   ;
+     120         804 :     else if (type == GrB_FP64  ) op = GrB_EQ_FP64   ;
+     121             :     #if 0
+     122             :     else if (type == GxB_FC32  ) op = GxB_EQ_FC32   ;
+     123             :     else if (type == GxB_FC64  ) op = GxB_EQ_FC64   ;
+     124             :     #endif
+     125             : 
+     126        3181 :     LG_ASSERT_MSG (op != NULL, GrB_NOT_IMPLEMENTED, "type not supported") ;
+     127             : 
+     128             :     //--------------------------------------------------------------------------
+     129             :     // C = A .* B, where the structure of C is the intersection of A and B
+     130             :     //--------------------------------------------------------------------------
+     131             : 
+     132        3181 :     GRB_TRY (GrB_Matrix_new (&C, GrB_BOOL, nrows1, ncols1)) ;
+     133        2696 :     GRB_TRY (GrB_eWiseMult (C, NULL, NULL, op, A, B, NULL)) ;
+     134             : 
+     135             :     //--------------------------------------------------------------------------
+     136             :     // ensure C has the same number of entries as A and B
+     137             :     //--------------------------------------------------------------------------
+     138             : 
+     139             :     GrB_Index nvals ;
+     140        2210 :     GRB_TRY (GrB_Matrix_nvals (&nvals, C)) ;
+     141        2210 :     if (nvals != nvals1)
+     142             :     {
+     143             :         // structure of A and B are different
+     144         615 :         LG_FREE_WORK ;
+     145         615 :         (*result) = false ;
+     146         615 :         return (GrB_SUCCESS) ;
+     147             :     }
+     148             : 
+     149             :     //--------------------------------------------------------------------------
+     150             :     // result = and (C)
+     151             :     //--------------------------------------------------------------------------
+     152             : 
+     153        1595 :     GRB_TRY (GrB_reduce (result, NULL, GrB_LAND_MONOID_BOOL, C, NULL)) ;
+     154             : 
+     155             :     //--------------------------------------------------------------------------
+     156             :     // free workspace and return result
+     157             :     //--------------------------------------------------------------------------
+     158             : 
+     159        1595 :     LG_FREE_WORK ;
+     160        1595 :     return (GrB_SUCCESS) ;
+     161             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Matrix_IsEqualOp.c.func-sort-c.html b/src/utility/LAGraph_Matrix_IsEqualOp.c.func-sort-c.html new file mode 100644 index 0000000000..9a3b10e422 --- /dev/null +++ b/src/utility/LAGraph_Matrix_IsEqualOp.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Matrix_IsEqualOp.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Matrix_IsEqualOp.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:2929100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_Matrix_IsEqualOp128
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Matrix_IsEqualOp.c.func.html b/src/utility/LAGraph_Matrix_IsEqualOp.c.func.html new file mode 100644 index 0000000000..62a8f7a590 --- /dev/null +++ b/src/utility/LAGraph_Matrix_IsEqualOp.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Matrix_IsEqualOp.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Matrix_IsEqualOp.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:2929100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_Matrix_IsEqualOp128
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Matrix_IsEqualOp.c.gcov.html b/src/utility/LAGraph_Matrix_IsEqualOp.c.gcov.html new file mode 100644 index 0000000000..3a357272a6 --- /dev/null +++ b/src/utility/LAGraph_Matrix_IsEqualOp.c.gcov.html @@ -0,0 +1,199 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Matrix_IsEqualOp.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Matrix_IsEqualOp.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:2929100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_Matrix_IsEqualOp: compare two matrices with a given op
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // LAGraph_Matrix_IsEqualOp: check if two matrices are equal (same
+      19             : // size, structure, size, and values).
+      20             : 
+      21             : #define LG_FREE_WORK GrB_free (&C) ;
+      22             : 
+      23             : #include "LG_internal.h"
+      24             : 
+      25             : //------------------------------------------------------------------------------
+      26             : // LAGraph_Matrix_IsEqualOp: compare two matrices using a given operator
+      27             : //------------------------------------------------------------------------------
+      28             : 
+      29         128 : int LAGraph_Matrix_IsEqualOp
+      30             : (
+      31             :     // output:
+      32             :     bool *result,           // true if A == B, false if A != B or error
+      33             :     // input:
+      34             :     const GrB_Matrix A,
+      35             :     const GrB_Matrix B,
+      36             :     const GrB_BinaryOp op,        // comparator to use
+      37             :     char *msg
+      38             : )
+      39             : {
+      40             : 
+      41             :     //--------------------------------------------------------------------------
+      42             :     // check inputs
+      43             :     //--------------------------------------------------------------------------
+      44             : 
+      45         128 :     LG_CLEAR_MSG ;
+      46         128 :     GrB_Matrix C = NULL ;
+      47         128 :     LG_ASSERT (op != NULL && result != NULL, GrB_NULL_POINTER) ;
+      48             : 
+      49             :     //--------------------------------------------------------------------------
+      50             :     // check for NULL and aliased matrices
+      51             :     //--------------------------------------------------------------------------
+      52             : 
+      53         127 :     if (A == NULL || B == NULL || A == B)
+      54             :     {
+      55             :         // two NULL matrices are identical, as are two aliased matrices
+      56          32 :         (*result) = (A == B) ;
+      57          32 :         return (GrB_SUCCESS) ;
+      58             :     }
+      59             : 
+      60             :     //--------------------------------------------------------------------------
+      61             :     // compare the size of A and B
+      62             :     //--------------------------------------------------------------------------
+      63             : 
+      64             :     GrB_Index nrows1, ncols1, nrows2, ncols2 ;
+      65          95 :     GRB_TRY (GrB_Matrix_nrows (&nrows1, A)) ;
+      66          95 :     GRB_TRY (GrB_Matrix_nrows (&nrows2, B)) ;
+      67          95 :     GRB_TRY (GrB_Matrix_ncols (&ncols1, A)) ;
+      68          95 :     GRB_TRY (GrB_Matrix_ncols (&ncols2, B)) ;
+      69          95 :     if (nrows1 != nrows2 || ncols1 != ncols2)
+      70             :     {
+      71             :         // dimensions differ
+      72           4 :         (*result) = false ;
+      73           4 :         return (GrB_SUCCESS) ;
+      74             :     }
+      75             : 
+      76             :     //--------------------------------------------------------------------------
+      77             :     // compare the # entries in A and B
+      78             :     //--------------------------------------------------------------------------
+      79             : 
+      80             :     GrB_Index nvals1, nvals2 ;
+      81          91 :     GRB_TRY (GrB_Matrix_nvals (&nvals1, A)) ;
+      82          91 :     GRB_TRY (GrB_Matrix_nvals (&nvals2, B)) ;
+      83          91 :     if (nvals1 != nvals2)
+      84             :     {
+      85             :         // # of entries differ
+      86           4 :         (*result) = false ;
+      87           4 :         return (GrB_SUCCESS) ;
+      88             :     }
+      89             : 
+      90             :     //--------------------------------------------------------------------------
+      91             :     // C = A .* B, where the structure of C is the intersection of A and B
+      92             :     //--------------------------------------------------------------------------
+      93             : 
+      94          87 :     GRB_TRY (GrB_Matrix_new (&C, GrB_BOOL, nrows1, ncols1)) ;
+      95          51 :     GRB_TRY (GrB_eWiseMult (C, NULL, NULL, op, A, B, NULL)) ;
+      96             : 
+      97             :     //--------------------------------------------------------------------------
+      98             :     // ensure C has the same number of entries as A and B
+      99             :     //--------------------------------------------------------------------------
+     100             : 
+     101             :     GrB_Index nvals ;
+     102          24 :     GRB_TRY (GrB_Matrix_nvals (&nvals, C)) ;
+     103          24 :     if (nvals != nvals1)
+     104             :     {
+     105             :         // structure of A and B are different
+     106           2 :         LG_FREE_WORK ;
+     107           2 :         (*result) = false ;
+     108           2 :         return (GrB_SUCCESS) ;
+     109             :     }
+     110             : 
+     111             :     //--------------------------------------------------------------------------
+     112             :     // result = and (C)
+     113             :     //--------------------------------------------------------------------------
+     114             : 
+     115          22 :     GRB_TRY (GrB_reduce (result, NULL, GrB_LAND_MONOID_BOOL, C, NULL)) ;
+     116             : 
+     117             :     //--------------------------------------------------------------------------
+     118             :     // free workspace and return result
+     119             :     //--------------------------------------------------------------------------
+     120             : 
+     121          22 :     LG_FREE_WORK ;
+     122          22 :     return (GrB_SUCCESS) ;
+     123             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Matrix_Print.c.func-sort-c.html b/src/utility/LAGraph_Matrix_Print.c.func-sort-c.html new file mode 100644 index 0000000000..710c5fb682 --- /dev/null +++ b/src/utility/LAGraph_Matrix_Print.c.func-sort-c.html @@ -0,0 +1,120 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Matrix_Print.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Matrix_Print.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3939100.0 %
Date:2024-08-29 20:08:04Functions:1212100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_Matrix_Print_UINT168
LG_Matrix_Print_UINT88
LG_Matrix_Print_UINT329
LG_Matrix_Print_INT812
LG_Matrix_Print_INT1613
LG_Matrix_Print_FP3215
LG_Matrix_Print_UINT6419
LG_Matrix_Print_INT6443
LG_Matrix_Print_INT3282
LG_Matrix_Print_FP64203
LG_Matrix_Print_BOOL325
LAGraph_Matrix_Print738
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Matrix_Print.c.func.html b/src/utility/LAGraph_Matrix_Print.c.func.html new file mode 100644 index 0000000000..44eed9df22 --- /dev/null +++ b/src/utility/LAGraph_Matrix_Print.c.func.html @@ -0,0 +1,120 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Matrix_Print.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Matrix_Print.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3939100.0 %
Date:2024-08-29 20:08:04Functions:1212100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_Matrix_Print738
LG_Matrix_Print_BOOL325
LG_Matrix_Print_FP3215
LG_Matrix_Print_FP64203
LG_Matrix_Print_INT1613
LG_Matrix_Print_INT3282
LG_Matrix_Print_INT6443
LG_Matrix_Print_INT812
LG_Matrix_Print_UINT168
LG_Matrix_Print_UINT329
LG_Matrix_Print_UINT6419
LG_Matrix_Print_UINT88
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Matrix_Print.c.gcov.html b/src/utility/LAGraph_Matrix_Print.c.gcov.html new file mode 100644 index 0000000000..b1054b1db7 --- /dev/null +++ b/src/utility/LAGraph_Matrix_Print.c.gcov.html @@ -0,0 +1,283 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Matrix_Print.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Matrix_Print.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:3939100.0 %
Date:2024-08-29 20:08:04Functions:1212100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_Matrix_Print:  pretty-print a matrix
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // LAGraph_Matrix_Print:  pretty-print a matrix.  The type is either derived
+      19             : // from GxB_Matrix_type (if available) or assumed to be GrB_FP64 otherwise,
+      20             : // or passed in as a parameter.
+      21             : 
+      22             : #include "LG_internal.h"
+      23             : 
+      24             : #undef  LG_FREE_WORK
+      25             : #define LG_FREE_WORK                    \
+      26             : {                                       \
+      27             :     LAGraph_Free ((void **) &I, NULL) ; \
+      28             :     LAGraph_Free ((void **) &J, NULL) ; \
+      29             :     LAGraph_Free ((void **) &X, NULL) ; \
+      30             : }
+      31             : 
+      32             : #undef  LG_FREE_ALL
+      33             : #define LG_FREE_ALL LG_FREE_WORK
+      34             : 
+      35             : //------------------------------------------------------------------------------
+      36             : // LG_Matrix_Print_TYPE: print with the specified type
+      37             : //------------------------------------------------------------------------------
+      38             : 
+      39             : #define LG_MATRIX_PRINT(suffix,ctype,gtype,fmt1,fmt2)                       \
+      40             : int LG_Matrix_Print_ ## suffix                                              \
+      41             : (                                                                           \
+      42             :     GrB_Matrix A, LAGraph_PrintLevel pr, FILE *f, char *msg                 \
+      43             : )                                                                           \
+      44             : {                                                                           \
+      45             :     LG_CLEAR_MSG ;                                                          \
+      46             :     ctype *X = NULL ;                                                       \
+      47             :     GrB_Index *I = NULL, *J = NULL ;                                        \
+      48             :     LG_ASSERT (A != NULL && f != NULL, GrB_NULL_POINTER) ;                  \
+      49             :     int prl = (int) pr ;                                                    \
+      50             :     if (prl <= 0) return (GrB_SUCCESS) ;                                    \
+      51             :     /* get basic properties */                                              \
+      52             :     GrB_Index nrows, ncols, nvals ;                                         \
+      53             :     GRB_TRY (GrB_Matrix_nrows (&nrows, A)) ;                                \
+      54             :     GRB_TRY (GrB_Matrix_ncols (&ncols, A)) ;                                \
+      55             :     GRB_TRY (GrB_Matrix_nvals (&nvals, A)) ;                                \
+      56             :     /* print header line */                                                 \
+      57             :     FPRINTF (f, "%s matrix: %" PRIu64 "-by-%" PRIu64 " entries: %" PRIu64   \
+      58             :         "\n", LG_XSTR (gtype), nrows, ncols, nvals) ;                       \
+      59             :     if (prl <= 1) return (GrB_SUCCESS) ;                                    \
+      60             :     /* extract tuples */                                                    \
+      61             :     LG_TRY (LAGraph_Malloc ((void **) &I, nvals, sizeof (GrB_Index), msg)) ;\
+      62             :     LG_TRY (LAGraph_Malloc ((void **) &J, nvals, sizeof (GrB_Index), msg)) ;\
+      63             :     LG_TRY (LAGraph_Malloc ((void **) &X, nvals, sizeof (ctype), msg)) ;    \
+      64             :     GrB_Info info = GrB_Matrix_extractTuples (I, J, X, &nvals, A) ;         \
+      65             :     LG_ASSERT_MSG (info != GrB_DOMAIN_MISMATCH,                             \
+      66             :         GrB_NOT_IMPLEMENTED, "type not supported") ;                        \
+      67             :     GRB_TRY (info) ;                                                        \
+      68             :     /* determine the format */                                              \
+      69             :     char *format = (prl <= 3) ? fmt1 : fmt2 ;                               \
+      70             :     bool summary = (prl == 2 || prl == 4) && (nvals > LG_SHORT_LEN) ;       \
+      71             :     for (int64_t k = 0 ; k < nvals ; k++)                                   \
+      72             :     {                                                                       \
+      73             :         /* print the kth tuple */                                           \
+      74             :         GrB_Index i = I [k] ;                                               \
+      75             :         GrB_Index j = J [k] ;                                               \
+      76             :         ctype     x = X [k] ;                                               \
+      77             :         FPRINTF (f, "    (%" PRIu64 ", %" PRIu64 ")   ", i, j) ;            \
+      78             :         FPRINTF (f, format, x) ;                                            \
+      79             :         FPRINTF (f, "\n") ;                                                 \
+      80             :         if (summary && k > LG_SHORT_LEN)                                    \
+      81             :         {                                                                   \
+      82             :             /* quit early if a only a summary is requested */               \
+      83             :             FPRINTF (f, "    ...\n") ;                                      \
+      84             :             break ;                                                         \
+      85             :         }                                                                   \
+      86             :     }                                                                       \
+      87             :     LG_FREE_WORK ;                                                          \
+      88             :     return (GrB_SUCCESS) ;                                                  \
+      89             : }
+      90             : 
+      91        6322 : LG_MATRIX_PRINT (BOOL  , bool    , GrB_BOOL  , "%d"  , "%d"    ) ;
+      92         100 : LG_MATRIX_PRINT (INT8  , int8_t  , GrB_INT8  , "%d"  , "%d"    ) ;
+      93         113 : LG_MATRIX_PRINT (INT16 , int16_t , GrB_INT16 , "%d"  , "%d"    ) ;
+      94         566 : LG_MATRIX_PRINT (INT32 , int32_t , GrB_INT32 , "%" PRId32, "%" PRId32  ) ;
+      95         409 : LG_MATRIX_PRINT (INT64 , int64_t , GrB_INT64 , "%" PRId64, "%" PRId64  ) ;
+      96          64 : LG_MATRIX_PRINT (UINT8 , uint8_t , GrB_UINT8 , "%d"  , "%d"    ) ;
+      97          64 : LG_MATRIX_PRINT (UINT16, uint16_t, GrB_UINT16, "%d"  , "%d"    ) ;
+      98         221 : LG_MATRIX_PRINT (UINT32, uint32_t, GrB_UINT32, "%" PRIu32, "%" PRIu32  ) ;
+      99         288 : LG_MATRIX_PRINT (UINT64, uint64_t, GrB_UINT64, "%" PRIu64, "%" PRIu64  ) ;
+     100         156 : LG_MATRIX_PRINT (FP32  , float   , GrB_FP32  , "%g"  , "%0.7g" ) ;
+     101        4421 : LG_MATRIX_PRINT (FP64  , double  , GrB_FP64  , "%g"  , "%0.15g") ;
+     102             : #if 0
+     103             : LG_MATRIX_PRINT (FC32  , GxB_FC32_t, GxB_FC32, ...) ;
+     104             : LG_MATRIX_PRINT (FC64  , GxB_FC64_t, GxB_FC64, ...) ;
+     105             : #endif
+     106             : 
+     107             : #undef  LG_FREE_WORK
+     108             : #define LG_FREE_WORK ;
+     109             : #undef  LG_FREE_ALL
+     110             : #define LG_FREE_ALL ;
+     111             : 
+     112             : //------------------------------------------------------------------------------
+     113             : // LAGraph_Matrix_Print: automatically determine the type
+     114             : //------------------------------------------------------------------------------
+     115             : 
+     116         738 : int LAGraph_Matrix_Print
+     117             : (
+     118             :     // input:
+     119             :     const GrB_Matrix A,     // matrix to pretty-print to the file
+     120             :     LAGraph_PrintLevel pr,  // print level (0 to 5)
+     121             :     FILE *f,            // file to write it to, must be already open; use
+     122             :                         // stdout or stderr to print to those locations.
+     123             :     char *msg
+     124             : )
+     125             : {
+     126             : 
+     127             :     //--------------------------------------------------------------------------
+     128             :     // check inputs
+     129             :     //--------------------------------------------------------------------------
+     130             : 
+     131         738 :     LG_CLEAR_MSG ;
+     132         738 :     LG_ASSERT (A != NULL && f != NULL, GrB_NULL_POINTER) ;
+     133             : 
+     134             :     //--------------------------------------------------------------------------
+     135             :     // determine the type
+     136             :     //--------------------------------------------------------------------------
+     137             : 
+     138             :     GrB_Type type ;
+     139             :     char typename [LAGRAPH_MAX_NAME_LEN] ;
+     140         738 :     LG_TRY (LAGraph_Matrix_TypeName (typename, A, msg)) ;
+     141         738 :     LG_TRY (LAGraph_TypeFromName (&type, typename, msg)) ;
+     142             : 
+     143             :     //--------------------------------------------------------------------------
+     144             :     // print the matrix
+     145             :     //--------------------------------------------------------------------------
+     146             : 
+     147         738 :     if (type == GrB_BOOL)
+     148             :     {
+     149         325 :         return (LG_Matrix_Print_BOOL (A, pr, f, msg)) ;
+     150             :     }
+     151         413 :     else if (type == GrB_INT8)
+     152             :     {
+     153          12 :         return (LG_Matrix_Print_INT8 (A, pr, f, msg)) ;
+     154             :     }
+     155         401 :     else if (type == GrB_INT16)
+     156             :     {
+     157          13 :         return (LG_Matrix_Print_INT16 (A, pr, f, msg)) ;
+     158             :     }
+     159         388 :     else if (type == GrB_INT32)
+     160             :     {
+     161          82 :         return (LG_Matrix_Print_INT32 (A, pr, f, msg)) ;
+     162             :     }
+     163         306 :     else if (type == GrB_INT64)
+     164             :     {
+     165          43 :         return (LG_Matrix_Print_INT64 (A, pr, f, msg)) ;
+     166             :     }
+     167         263 :     else if (type == GrB_UINT8)
+     168             :     {
+     169           8 :         return (LG_Matrix_Print_UINT8 (A, pr, f, msg)) ;
+     170             :     }
+     171         255 :     else if (type == GrB_UINT16)
+     172             :     {
+     173           8 :         return (LG_Matrix_Print_UINT16 (A, pr, f, msg)) ;
+     174             :     }
+     175         247 :     else if (type == GrB_UINT32)
+     176             :     {
+     177           9 :         return (LG_Matrix_Print_UINT32 (A, pr, f, msg)) ;
+     178             :     }
+     179         238 :     else if (type == GrB_UINT64)
+     180             :     {
+     181          19 :         return (LG_Matrix_Print_UINT64 (A, pr, f, msg)) ;
+     182             :     }
+     183         219 :     else if (type == GrB_FP32)
+     184             :     {
+     185          15 :         return (LG_Matrix_Print_FP32 (A, pr, f, msg)) ;
+     186             :     }
+     187         204 :     else if (type == GrB_FP64)
+     188             :     {
+     189         203 :         return (LG_Matrix_Print_FP64 (A, pr, f, msg)) ;
+     190             :     }
+     191             :     #if 0
+     192             :     else if (type == GxB_FC32)
+     193             :     {
+     194             :         return (LG_Matrix_Print_FC32 (A, pr, f, msg)) ;
+     195             :     }
+     196             :     else if (type == GxB_FC32)
+     197             :     {
+     198             :         return (LG_Matrix_Print_FC64 (A, pr, f, msg)) ;
+     199             :     }
+     200             :     #endif
+     201             :     else
+     202             :     {
+     203           1 :         LG_ASSERT_MSG (false,
+     204             :             GrB_NOT_IMPLEMENTED, "user-defined types not supported") ;
+     205             :         return (GrB_SUCCESS) ;
+     206             :     }
+     207             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Matrix_Structure.c.func-sort-c.html b/src/utility/LAGraph_Matrix_Structure.c.func-sort-c.html new file mode 100644 index 0000000000..7d2d33bbfc --- /dev/null +++ b/src/utility/LAGraph_Matrix_Structure.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Matrix_Structure.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Matrix_Structure.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1010100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_Matrix_Structure563
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Matrix_Structure.c.func.html b/src/utility/LAGraph_Matrix_Structure.c.func.html new file mode 100644 index 0000000000..68ef7b9d1e --- /dev/null +++ b/src/utility/LAGraph_Matrix_Structure.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Matrix_Structure.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Matrix_Structure.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1010100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_Matrix_Structure563
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Matrix_Structure.c.gcov.html b/src/utility/LAGraph_Matrix_Structure.c.gcov.html new file mode 100644 index 0000000000..9060341c80 --- /dev/null +++ b/src/utility/LAGraph_Matrix_Structure.c.gcov.html @@ -0,0 +1,139 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Matrix_Structure.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Matrix_Structure.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1010100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_Matrix_Structure: return the structure of a matrix
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis and Scott Kolodziej, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // LAGraph_Matrix_Structure: return the structure of a matrix as a boolean
+      19             : // matrix, where C(i,j)=true if the entry A(i,j) is present in the matrix A.
+      20             : 
+      21             : #define LG_FREE_ALL GrB_free (C) ;
+      22             : 
+      23             : #include "LG_internal.h"
+      24             : 
+      25         563 : int LAGraph_Matrix_Structure
+      26             : (
+      27             :     // output:
+      28             :     GrB_Matrix *C,  // a boolean matrix with same structure of A, with C(i,j)
+      29             :                     // set to true if A(i,j) appears in the sparsity structure
+      30             :                     // of A.
+      31             :     // input:
+      32             :     GrB_Matrix A,
+      33             :     char *msg
+      34             : )
+      35             : {
+      36             : 
+      37             :     //--------------------------------------------------------------------------
+      38             :     // check inputs
+      39             :     //--------------------------------------------------------------------------
+      40             : 
+      41         563 :     LG_CLEAR_MSG ;
+      42             :     GrB_Index nrows, ncols ;
+      43         563 :     LG_ASSERT_MSG (C != NULL, GrB_NULL_POINTER, "&C != NULL") ;
+      44         562 :     LG_ASSERT (A != NULL, GrB_NULL_POINTER) ;
+      45         561 :     (*C) = NULL ;
+      46             : 
+      47             :     //--------------------------------------------------------------------------
+      48             :     // get the size of A
+      49             :     //--------------------------------------------------------------------------
+      50             : 
+      51         561 :     GRB_TRY (GrB_Matrix_nrows (&nrows, A)) ;
+      52         561 :     GRB_TRY (GrB_Matrix_ncols (&ncols, A)) ;
+      53             : 
+      54             :     //--------------------------------------------------------------------------
+      55             :     // C<s(A)> = true
+      56             :     //--------------------------------------------------------------------------
+      57             : 
+      58         561 :     GRB_TRY (GrB_Matrix_new (C, GrB_BOOL, nrows, ncols)) ;
+      59         537 :     GRB_TRY (GrB_assign (*C, A, NULL, (bool) true,
+      60             :         GrB_ALL, nrows, GrB_ALL, nrows, GrB_DESC_S)) ;
+      61             : 
+      62         512 :     return (GrB_SUCCESS) ;
+      63             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_NameOfType.c.func-sort-c.html b/src/utility/LAGraph_NameOfType.c.func-sort-c.html new file mode 100644 index 0000000000..218c0f66ca --- /dev/null +++ b/src/utility/LAGraph_NameOfType.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_NameOfType.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_NameOfType.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1818100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_NameOfType15
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_NameOfType.c.func.html b/src/utility/LAGraph_NameOfType.c.func.html new file mode 100644 index 0000000000..0acdd8f84d --- /dev/null +++ b/src/utility/LAGraph_NameOfType.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_NameOfType.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_NameOfType.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1818100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_NameOfType15
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_NameOfType.c.gcov.html b/src/utility/LAGraph_NameOfType.c.gcov.html new file mode 100644 index 0000000000..32171cad20 --- /dev/null +++ b/src/utility/LAGraph_NameOfType.c.gcov.html @@ -0,0 +1,142 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_NameOfType.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_NameOfType.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1818100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_NameOfType: return the C name of a GraphBLAS GrB_Type
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include "LG_internal.h"
+      19             : 
+      20          15 : int LAGraph_NameOfType
+      21             : (
+      22             :     // output:
+      23             :     char *name,     // name of the type: user provided array of size at
+      24             :                     // least LAGRAPH_MAX_NAME_LEN.
+      25             :     // input:
+      26             :     GrB_Type type,  // GraphBLAS type
+      27             :     char *msg
+      28             : )
+      29             : {
+      30             : 
+      31             :     //--------------------------------------------------------------------------
+      32             :     // check inputs
+      33             :     //--------------------------------------------------------------------------
+      34             : 
+      35          15 :     LG_CLEAR_MSG ;
+      36          15 :     LG_ASSERT (type != NULL, GrB_NULL_POINTER) ;
+      37          13 :     LG_ASSERT (name != NULL, GrB_NULL_POINTER) ;
+      38             : 
+      39             :     //--------------------------------------------------------------------------
+      40             :     // determine the name of the type
+      41             :     //--------------------------------------------------------------------------
+      42             : 
+      43          12 :         if      (type == GrB_BOOL  ) strcpy (name, "bool")     ;
+      44          11 :         else if (type == GrB_INT8  ) strcpy (name, "int8_t")   ;
+      45          10 :         else if (type == GrB_INT16 ) strcpy (name, "int16_t")  ;
+      46           9 :         else if (type == GrB_INT32 ) strcpy (name, "int32_t")  ;
+      47           8 :         else if (type == GrB_INT64 ) strcpy (name, "int64_t")  ;
+      48           7 :         else if (type == GrB_UINT8 ) strcpy (name, "uint8_t")  ;
+      49           6 :         else if (type == GrB_UINT16) strcpy (name, "uint16_t") ;
+      50           5 :         else if (type == GrB_UINT32) strcpy (name, "uint32_t") ;
+      51           4 :         else if (type == GrB_UINT64) strcpy (name, "uint64_t") ;
+      52           3 :         else if (type == GrB_FP32  ) strcpy (name, "float")    ;
+      53           2 :         else if (type == GrB_FP64  ) strcpy (name, "double")   ;
+      54             :         #if 0
+      55             :         else if (type == GxB_FC32  ) strcpy (name, "float complex") ;
+      56             :         else if (type == GxB_FC64  ) strcpy (name, "double complex") ;
+      57             :         #endif
+      58             :         else
+      59             :         {
+      60           1 :             name [0] = '\0' ;
+      61           1 :             LG_ASSERT_MSG (false,
+      62             :                 GrB_NOT_IMPLEMENTED, "user-defined types not supported") ;
+      63             :         }
+      64          11 :         return (GrB_SUCCESS) ;
+      65             : 
+      66             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_New.c.func-sort-c.html b/src/utility/LAGraph_New.c.func-sort-c.html new file mode 100644 index 0000000000..6023dd5229 --- /dev/null +++ b/src/utility/LAGraph_New.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_New.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_New.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:2222100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_New1146
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_New.c.func.html b/src/utility/LAGraph_New.c.func.html new file mode 100644 index 0000000000..923b96b39a --- /dev/null +++ b/src/utility/LAGraph_New.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_New.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_New.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:2222100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_New1146
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_New.c.gcov.html b/src/utility/LAGraph_New.c.gcov.html new file mode 100644 index 0000000000..181d896920 --- /dev/null +++ b/src/utility/LAGraph_New.c.gcov.html @@ -0,0 +1,171 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_New.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_New.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:2222100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_New:  create a new graph
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // If succesful, the matrix A is moved into G->A, and the caller's A is set
+      19             : // to NULL.
+      20             : 
+      21             : #include "LG_internal.h"
+      22             : 
+      23        1146 : int LAGraph_New
+      24             : (
+      25             :     // output:
+      26             :     LAGraph_Graph *G,   // the graph to create, NULL if failure
+      27             :     // input/output:
+      28             :     GrB_Matrix    *A,   // the adjacency matrix of the graph, may be NULL.
+      29             :                         // A is moved into G as G->A, and A itself is set
+      30             :                         // to NULL to denote that is now a part of G.
+      31             :                         // That is, { G->A = A ; A = NULL ; } is performed.
+      32             :                         // When G is deleted, G->A is freed.  If A is NULL,
+      33             :                         // the graph is invalid until G->A is set.
+      34             :     // input:
+      35             :     LAGraph_Kind kind,  // the kind of graph. This may be LAGRAPH_UNKNOWN,
+      36             :                         // which must then be revised later before the
+      37             :                         // graph can be used.
+      38             :     char *msg
+      39             : )
+      40             : {
+      41             : 
+      42             :     //--------------------------------------------------------------------------
+      43             :     // check inputs
+      44             :     //--------------------------------------------------------------------------
+      45             : 
+      46        1146 :     LG_CLEAR_MSG ;
+      47        1146 :     LG_ASSERT (G != NULL, GrB_NULL_POINTER) ;
+      48             : 
+      49             :     //--------------------------------------------------------------------------
+      50             :     // allocate the graph
+      51             :     //--------------------------------------------------------------------------
+      52             : 
+      53        1144 :     LG_TRY (LAGraph_Malloc ((void **) G, 1,
+      54             :         sizeof (struct LAGraph_Graph_struct), msg)) ;
+      55             : 
+      56             :     //--------------------------------------------------------------------------
+      57             :     // initialize its members
+      58             :     //--------------------------------------------------------------------------
+      59             : 
+      60        1136 :     (*G)->A = NULL ;
+      61        1136 :     (*G)->kind = LAGraph_KIND_UNKNOWN ;
+      62        1136 :     (*G)->AT = NULL ;
+      63        1136 :     (*G)->out_degree = NULL ;
+      64        1136 :     (*G)->in_degree = NULL ;
+      65        1136 :     (*G)->is_symmetric_structure = LAGRAPH_UNKNOWN ;
+      66        1136 :     (*G)->nself_edges = LAGRAPH_UNKNOWN ;
+      67        1136 :     (*G)->emin = NULL ;
+      68        1136 :     (*G)->emin_state = LAGRAPH_UNKNOWN ;
+      69        1136 :     (*G)->emax = NULL ;
+      70        1136 :     (*G)->emax_state = LAGRAPH_UNKNOWN ;
+      71             : 
+      72             :     //--------------------------------------------------------------------------
+      73             :     // assign its primary components
+      74             :     //--------------------------------------------------------------------------
+      75             : 
+      76        1136 :     if ((A != NULL) && (*A != NULL))
+      77             :     {
+      78             :         // move &A into the graph and set &A to NULL to denote to the caller
+      79             :         // that it is now a component of G.  The graph G is not opaque, so the
+      80             :         // caller can get A back with A = G->A, but this helps with memory
+      81             :         // management, since LAGraph_Delete (&G,msg) frees G->A, and if the
+      82             :         // caller also does GrB_free (&A), a double-free would occur if this
+      83             :         // move does not set A to NULL.
+      84        1134 :         (*G)->A = (*A) ;
+      85        1134 :         (*A) = NULL ;
+      86             : 
+      87        1134 :         (*G)->kind = kind ;
+      88        1134 :         (*G)->is_symmetric_structure =
+      89             :             (kind == LAGraph_ADJACENCY_UNDIRECTED)
+      90             :             ? LAGraph_TRUE
+      91        1134 :             : LAGRAPH_UNKNOWN ;
+      92             :     }
+      93             : 
+      94        1136 :     return (GrB_SUCCESS) ;
+      95             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Realloc.c.func-sort-c.html b/src/utility/LAGraph_Realloc.c.func-sort-c.html new file mode 100644 index 0000000000..ef156119bc --- /dev/null +++ b/src/utility/LAGraph_Realloc.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Realloc.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Realloc.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:2525100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_Realloc109
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Realloc.c.func.html b/src/utility/LAGraph_Realloc.c.func.html new file mode 100644 index 0000000000..39251528b3 --- /dev/null +++ b/src/utility/LAGraph_Realloc.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Realloc.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Realloc.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:2525100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_Realloc109
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Realloc.c.gcov.html b/src/utility/LAGraph_Realloc.c.gcov.html new file mode 100644 index 0000000000..1f87fbed41 --- /dev/null +++ b/src/utility/LAGraph_Realloc.c.gcov.html @@ -0,0 +1,219 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Realloc.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Realloc.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:2525100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_Realloc: wrapper for realloc
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // If p is non-NULL on input, it points to a previously allocated object of
+      19             : // size at least nitems_old * size_of_item.  The object is reallocated to be of
+      20             : // size at least nitems_new * size_of_item.  If p is NULL on input, then a new
+      21             : // object of that size is allocated.  On success, a pointer to the new object
+      22             : // is returned, and ok is returned as true.  If the allocation fails, ok is set
+      23             : // to false and a pointer to the old (unmodified) object is returned.
+      24             : 
+      25             : // Usage:
+      26             : 
+      27             : //  int status = LAGraph_Realloc (&p, nitems_new, nitems_old, size_of_item, msg)
+      28             : //  if (status == GrB_SUCCESS)
+      29             : //  {
+      30             : //      p points to a block of at least nitems_new*size_of_item bytes and
+      31             : //      the first part, of size min(nitems_new,nitems_old)*size_of_item,
+      32             : //      has the same content as the old memory block if it was present.
+      33             : //  }
+      34             : //  else
+      35             : //  {
+      36             : //      p points to the old block, unchanged.  This case never occurs if
+      37             : //      nitems_new < nitems_old.
+      38             : //  }
+      39             : 
+      40             : #include "LG_internal.h"
+      41             : 
+      42         109 : int LAGraph_Realloc
+      43             : (
+      44             :     // input/output:
+      45             :     void **p,               // old block to reallocate
+      46             :     // input:
+      47             :     size_t nitems_new,      // new number of items in the object
+      48             :     size_t nitems_old,      // old number of items in the object
+      49             :     size_t size_of_item,    // size of each item
+      50             :     char *msg
+      51             : )
+      52             : {
+      53             : 
+      54             :     //--------------------------------------------------------------------------
+      55             :     // check inputs
+      56             :     //--------------------------------------------------------------------------
+      57             : 
+      58         109 :     LG_CLEAR_MSG ;
+      59         109 :     LG_ASSERT (p != NULL, GrB_NULL_POINTER) ;
+      60             : 
+      61             :     //--------------------------------------------------------------------------
+      62             :     // malloc a new block if p is NULL on input
+      63             :     //--------------------------------------------------------------------------
+      64             : 
+      65         109 :     if ((*p) == NULL)
+      66             :     {
+      67           1 :         LG_TRY (LAGraph_Malloc (p, nitems_new, size_of_item, msg)) ;
+      68           1 :         return (GrB_SUCCESS) ;
+      69             :     }
+      70             : 
+      71             :     //--------------------------------------------------------------------------
+      72             :     // check inputs
+      73             :     //--------------------------------------------------------------------------
+      74             : 
+      75             :     // make sure at least one item is allocated
+      76         108 :     nitems_old = LAGRAPH_MAX (1, nitems_old) ;
+      77         108 :     nitems_new = LAGRAPH_MAX (1, nitems_new) ;
+      78             : 
+      79             :     // make sure at least one byte is allocated
+      80         108 :     size_of_item = LAGRAPH_MAX (1, size_of_item) ;
+      81             : 
+      82             :     size_t newsize, oldsize ;
+      83         108 :     bool ok = LG_Multiply_size_t (&newsize, nitems_new, size_of_item)
+      84         108 :            && LG_Multiply_size_t (&oldsize, nitems_old, size_of_item) ;
+      85         108 :     if (!ok)
+      86             :     {
+      87             :         // overflow
+      88           1 :         return (GrB_OUT_OF_MEMORY) ;
+      89             :     }
+      90             : 
+      91             :     //--------------------------------------------------------------------------
+      92             :     // reallocate an existing block to accommodate the change in # of items
+      93             :     //--------------------------------------------------------------------------
+      94             : 
+      95             :     //--------------------------------------------------------------------------
+      96             :     // check for quick return
+      97             :     //--------------------------------------------------------------------------
+      98             : 
+      99         107 :     if (newsize == oldsize)
+     100             :     {
+     101             :         // If the block does not change, or is shrinking but only by a small
+     102             :         // amount, or is growing but still fits inside the existing block,
+     103             :         // then leave the block as-is.
+     104          71 :         return (GrB_SUCCESS) ;
+     105             :     }
+     106             : 
+     107             :     //--------------------------------------------------------------------------
+     108             :     // reallocate the memory, or use malloc/memcpy/free
+     109             :     //--------------------------------------------------------------------------
+     110             : 
+     111          36 :     void *pnew = NULL ;
+     112             : 
+     113          36 :     if (LAGraph_Realloc_function == NULL)
+     114             :     {
+     115             : 
+     116             :         //----------------------------------------------------------------------
+     117             :         // use malloc/memcpy/free
+     118             :         //----------------------------------------------------------------------
+     119             : 
+     120             :         // allocate the new space
+     121           1 :         LG_TRY (LAGraph_Malloc (&pnew, nitems_new, size_of_item, msg)) ;
+     122             :         // copy over the data from the old block to the new block
+     123             :         // copy from the old to the new space
+     124           1 :         memcpy (pnew, *p, LAGRAPH_MIN (oldsize, newsize)) ;
+     125             :         // free the old space
+     126           1 :         LG_TRY (LAGraph_Free (p, msg)) ;
+     127           1 :         (*p) = pnew ;
+     128             : 
+     129             :     }
+     130             :     else
+     131             :     {
+     132             : 
+     133             :         //----------------------------------------------------------------------
+     134             :         // use realloc
+     135             :         //----------------------------------------------------------------------
+     136             : 
+     137          35 :         pnew = LAGraph_Realloc_function (*p, newsize) ;
+     138          35 :         if (pnew == NULL) return (GrB_OUT_OF_MEMORY) ;
+     139          35 :         (*p) = pnew ;
+     140             :     }
+     141             : 
+     142          36 :     return (GrB_SUCCESS) ;
+     143             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_SetNumThreads.c.func-sort-c.html b/src/utility/LAGraph_SetNumThreads.c.func-sort-c.html new file mode 100644 index 0000000000..2abe1edefc --- /dev/null +++ b/src/utility/LAGraph_SetNumThreads.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_SetNumThreads.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_SetNumThreads.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:88100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_SetNumThreads12
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_SetNumThreads.c.func.html b/src/utility/LAGraph_SetNumThreads.c.func.html new file mode 100644 index 0000000000..2e0349b7d0 --- /dev/null +++ b/src/utility/LAGraph_SetNumThreads.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_SetNumThreads.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_SetNumThreads.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:88100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_SetNumThreads12
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_SetNumThreads.c.gcov.html b/src/utility/LAGraph_SetNumThreads.c.gcov.html new file mode 100644 index 0000000000..f84307b949 --- /dev/null +++ b/src/utility/LAGraph_SetNumThreads.c.gcov.html @@ -0,0 +1,131 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_SetNumThreads.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_SetNumThreads.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:88100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_SetNumThreads: set the # of threads to use
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include "LG_internal.h"
+      19             : 
+      20          12 : int LAGraph_SetNumThreads
+      21             : (
+      22             :     // input:
+      23             :     int nthreads_outer,
+      24             :     int nthreads_inner,
+      25             :     char *msg
+      26             : )
+      27             : {
+      28             : 
+      29             :     //--------------------------------------------------------------------------
+      30             :     // check inputs
+      31             :     //--------------------------------------------------------------------------
+      32             : 
+      33          12 :     LG_CLEAR_MSG ;
+      34             : 
+      35             :     //--------------------------------------------------------------------------
+      36             :     // set number of threads to use
+      37             :     //--------------------------------------------------------------------------
+      38             : 
+      39          12 :     nthreads_outer = LAGRAPH_MAX (nthreads_outer, 1) ;
+      40          12 :     nthreads_inner = LAGRAPH_MAX (nthreads_inner, 1) ;
+      41             : 
+      42             :     #if LAGRAPH_SUITESPARSE
+      43             :     {
+      44             :         // SuiteSparse:GraphBLAS: set # of threads with global setting
+      45          12 :         GRB_TRY (GxB_set (GxB_NTHREADS, nthreads_inner)) ;
+      46             :     }
+      47             :     #endif
+      48             : 
+      49             :     // set # of LAGraph threads
+      50          12 :     LG_nthreads_outer = nthreads_outer ;    // for LAGraph itself, if nested
+      51             :                                             // regions call GraphBLAS
+      52          12 :     LG_nthreads_inner = nthreads_inner ;    // for lower-level parallelism
+      53             : 
+      54          12 :     return (GrB_SUCCESS) ;
+      55             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_SizeOfType.c.func-sort-c.html b/src/utility/LAGraph_SizeOfType.c.func-sort-c.html new file mode 100644 index 0000000000..9e65bfcf5c --- /dev/null +++ b/src/utility/LAGraph_SizeOfType.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_SizeOfType.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_SizeOfType.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:66100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_SizeOfType15
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_SizeOfType.c.func.html b/src/utility/LAGraph_SizeOfType.c.func.html new file mode 100644 index 0000000000..923575dfcf --- /dev/null +++ b/src/utility/LAGraph_SizeOfType.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_SizeOfType.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_SizeOfType.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:66100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_SizeOfType15
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_SizeOfType.c.gcov.html b/src/utility/LAGraph_SizeOfType.c.gcov.html new file mode 100644 index 0000000000..c1674fd499 --- /dev/null +++ b/src/utility/LAGraph_SizeOfType.c.gcov.html @@ -0,0 +1,150 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_SizeOfType.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_SizeOfType.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:66100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_SizeOfType: return the sizeof(...) of a GraphBLAS GrB_Type
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include "LG_internal.h"
+      19             : 
+      20          15 : int LAGraph_SizeOfType
+      21             : (
+      22             :     // output:
+      23             :     size_t *size,   // size of the type
+      24             :     // input:
+      25             :     GrB_Type type,  // GraphBLAS type
+      26             :     char *msg
+      27             : )
+      28             : {
+      29             : 
+      30             :     //--------------------------------------------------------------------------
+      31             :     // check inputs
+      32             :     //--------------------------------------------------------------------------
+      33             : 
+      34          15 :     LG_CLEAR_MSG ;
+      35          15 :     LG_ASSERT (type != NULL, GrB_NULL_POINTER) ;
+      36          13 :     LG_ASSERT (size != NULL, GrB_NULL_POINTER) ;
+      37          12 :     (*size) = 0 ;
+      38             : 
+      39             :     //--------------------------------------------------------------------------
+      40             :     // determine the size of the type
+      41             :     //--------------------------------------------------------------------------
+      42             : 
+      43             :     #if LAGRAPH_SUITESPARSE
+      44             : 
+      45             :         // always succeeds, even for user-defined types, unless the
+      46             :         // type is an invalid object
+      47          12 :         return (GxB_Type_size (size, type)) ;
+      48             : 
+      49             :     #else
+      50             : 
+      51             :         if      (type == GrB_BOOL  ) (*size) = sizeof (bool)     ;
+      52             :         else if (type == GrB_INT8  ) (*size) = sizeof (int8_t)   ;
+      53             :         else if (type == GrB_INT16 ) (*size) = sizeof (int16_t)  ;
+      54             :         else if (type == GrB_INT32 ) (*size) = sizeof (int32_t)  ;
+      55             :         else if (type == GrB_INT64 ) (*size) = sizeof (int64_t)  ;
+      56             :         else if (type == GrB_UINT8 ) (*size) = sizeof (uint8_t)  ;
+      57             :         else if (type == GrB_UINT16) (*size) = sizeof (uint16_t) ;
+      58             :         else if (type == GrB_UINT32) (*size) = sizeof (uint32_t) ;
+      59             :         else if (type == GrB_UINT64) (*size) = sizeof (uint64_t) ;
+      60             :         else if (type == GrB_FP32  ) (*size) = sizeof (float)    ;
+      61             :         else if (type == GrB_FP64  ) (*size) = sizeof (double)   ;
+      62             :         #if 0
+      63             :         else if (type == GxB_FC32  ) (*size) = sizeof (GxB_FC32_t) ;
+      64             :         else if (type == GxB_FC64  ) (*size) = sizeof (GxB_FC64_t) ;
+      65             :         #endif
+      66             :         else
+      67             :         {
+      68             :             LG_ASSERT_MSG (false,
+      69             :                 GrB_NOT_IMPLEMENTED, "user-defined types not supported") ;
+      70             :         }
+      71             :         return (GrB_SUCCESS) ;
+      72             : 
+      73             :     #endif
+      74             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_TypeFromName.c.func-sort-c.html b/src/utility/LAGraph_TypeFromName.c.func-sort-c.html new file mode 100644 index 0000000000..0ecf03b5bd --- /dev/null +++ b/src/utility/LAGraph_TypeFromName.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_TypeFromName.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_TypeFromName.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:55100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_TypeFromName13620
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_TypeFromName.c.func.html b/src/utility/LAGraph_TypeFromName.c.func.html new file mode 100644 index 0000000000..2112263d1c --- /dev/null +++ b/src/utility/LAGraph_TypeFromName.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_TypeFromName.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_TypeFromName.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:55100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_TypeFromName13620
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_TypeFromName.c.gcov.html b/src/utility/LAGraph_TypeFromName.c.gcov.html new file mode 100644 index 0000000000..aebc855a40 --- /dev/null +++ b/src/utility/LAGraph_TypeFromName.c.gcov.html @@ -0,0 +1,154 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_TypeFromName.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_TypeFromName.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:55100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_TypeFromName: return the GrB_Type corresponding to its given name
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // This method works for any GraphBLAS library.  On input, name is a char array
+      19             : // of length at least LAGRAPH_MAX_NAME_LEN.
+      20             : 
+      21             : // Only built-in types are supported.  User-defined types are not supported.
+      22             : 
+      23             : #include "LG_internal.h"
+      24             : 
+      25       13620 : int LAGraph_TypeFromName
+      26             : (
+      27             :     // output:
+      28             :     GrB_Type *type, // GraphBLAS type
+      29             :     // input:
+      30             :     char *name,     // name of the type: a null-terminated string
+      31             :     char *msg
+      32             : )
+      33             : {
+      34             : 
+      35             :     //--------------------------------------------------------------------------
+      36             :     // check inputs
+      37             :     //--------------------------------------------------------------------------
+      38             : 
+      39       13620 :     LG_CLEAR_MSG ;
+      40       13620 :     LG_ASSERT (type != NULL, GrB_NULL_POINTER) ;
+      41       13620 :     LG_ASSERT (name != NULL, GrB_NULL_POINTER) ;
+      42             : 
+      43             :     //--------------------------------------------------------------------------
+      44             :     // determine the GrB_Type from its name
+      45             :     //--------------------------------------------------------------------------
+      46             : 
+      47             :     #if LAGRAPH_SUITESPARSE
+      48             : 
+      49       13620 :         return (GxB_Type_from_name (type, name)) ;
+      50             : 
+      51             :     #else
+      52             : 
+      53             :         if      (MATCHNAME (name, "bool"          )) (*type) = GrB_BOOL   ;
+      54             :         else if (MATCHNAME (name, "int8_t"        )) (*type) = GrB_INT8   ;
+      55             :         else if (MATCHNAME (name, "int16_t"       )) (*type) = GrB_INT16  ;
+      56             :         else if (MATCHNAME (name, "int32_t"       )) (*type) = GrB_INT32  ;
+      57             :         else if (MATCHNAME (name, "int64_t"       )) (*type) = GrB_INT64  ;
+      58             :         else if (MATCHNAME (name, "uint8_t"       )) (*type) = GrB_UINT8  ;
+      59             :         else if (MATCHNAME (name, "uint16_t"      )) (*type) = GrB_UINT16 ;
+      60             :         else if (MATCHNAME (name, "uint32_t"      )) (*type) = GrB_UINT32 ;
+      61             :         else if (MATCHNAME (name, "uint64_t"      )) (*type) = GrB_UINT64 ;
+      62             :         else if (MATCHNAME (name, "float"         )) (*type) = GrB_FP32   ;
+      63             :         else if (MATCHNAME (name, "double"        )) (*type) = GrB_FP64   ;
+      64             :         #if 0
+      65             :         // if complex types from SuiteSparse:GraphBLAS are added to LAGraph:
+      66             :         else if (MATCHNAME (name, "float complex" )) (*type) = GxB_FC32   ;
+      67             :         else if (MATCHNAME (name, "double complex")) (*type) = GxB_FC64   ;
+      68             :         #endif
+      69             :         else
+      70             :         {
+      71             :             (*type) = NULL ;
+      72             :             LG_ASSERT_MSGF (false, GrB_NOT_IMPLEMENTED,
+      73             :                 "type \"%s\" not supported", name) ;
+      74             :         }
+      75             :         return (GrB_SUCCESS) ;
+      76             : 
+      77             :     #endif
+      78             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_TypeName.c.func-sort-c.html b/src/utility/LAGraph_TypeName.c.func-sort-c.html new file mode 100644 index 0000000000..810f6338b7 --- /dev/null +++ b/src/utility/LAGraph_TypeName.c.func-sort-c.html @@ -0,0 +1,84 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_TypeName.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_TypeName.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1212100.0 %
Date:2024-08-29 20:08:04Functions:33100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_Scalar_TypeName3
LAGraph_Vector_TypeName25383
LAGraph_Matrix_TypeName29367
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_TypeName.c.func.html b/src/utility/LAGraph_TypeName.c.func.html new file mode 100644 index 0000000000..6c4c2374ec --- /dev/null +++ b/src/utility/LAGraph_TypeName.c.func.html @@ -0,0 +1,84 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_TypeName.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_TypeName.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1212100.0 %
Date:2024-08-29 20:08:04Functions:33100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_Matrix_TypeName29367
LAGraph_Scalar_TypeName3
LAGraph_Vector_TypeName25383
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_TypeName.c.gcov.html b/src/utility/LAGraph_TypeName.c.gcov.html new file mode 100644 index 0000000000..55393900ae --- /dev/null +++ b/src/utility/LAGraph_TypeName.c.gcov.html @@ -0,0 +1,232 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_TypeName.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_TypeName.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1212100.0 %
Date:2024-08-29 20:08:04Functions:33100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_*TypeName: return the name of type of a matrix, vector, or scalar
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // On input, "char *name" is a pointer to a pre-allocated array of size at
+      19             : // least LAGRAPH_MAX_NAME_LEN.  On output, the array is filled with a string
+      20             : // corresponding to the type of a GrB_Matrix, GrB_Vector, or GrB_Scalar.
+      21             : // For built-in types, the strings are defined as:
+      22             : 
+      23             : //      "bool"      GrB_BOOL
+      24             : //      "int8_t"    GrB_INT8
+      25             : //      "int16_t"   GrB_INT16
+      26             : //      "int32_t"   GrB_INT32
+      27             : //      "int64_t"   GrB_INT64
+      28             : //      "uint8_t"   GrB_UINT8
+      29             : //      "uint16_t"  GrB_UINT16
+      30             : //      "uint32_t"  GrB_UINT32
+      31             : //      "uint64_t"  GrB_UINT64
+      32             : //      "float"     GrB_FP32
+      33             : //      "double"    GrB_FP64
+      34             : 
+      35             : // SuiteSparse:GraphBLAS adds two extended types:
+      36             : //      "float complex"     GxB_FC32
+      37             : //      "double complex"    GxB_FC64
+      38             : 
+      39             : // For user-defined types, if SuiteSparse:GraphBLAS is used, then GrB_Type_new
+      40             : // can capture the type name, if called as follows, where the 2nd parameter has
+      41             : // the form "sizeof (T)" for some C typedef type T.
+      42             : //
+      43             : //      typedef ... myctype ;
+      44             : //      GrB_Type MyType ;
+      45             : //      GrB_Type_new (&MyType, sizeof (myctype)) ;
+      46             : //
+      47             : // In this case, LAGraph_*TypeName returns the string "myctype".
+      48             : 
+      49             : // Currently, these methods require SuiteSparse:GraphBLAS.  Other GraphBLAS
+      50             : // libraries will result in a return value of GrB_NOT_IMPLEMENTED, and the name
+      51             : // is returned as an empty string.  The type cannot be queried using the v2.0 C
+      52             : // API.  This will be resolved in a future C API spec.
+      53             : 
+      54             : #include "LG_internal.h"
+      55             : 
+      56             : //------------------------------------------------------------------------------
+      57             : // LAGraph_Matrix_TypeName: return the name of the GrB_Type of a GrB_Matrix
+      58             : //------------------------------------------------------------------------------
+      59             : 
+      60       29367 : int LAGraph_Matrix_TypeName
+      61             : (
+      62             :     // output:
+      63             :     char *name,     // name of the type of the matrix A (user-provided array
+      64             :                     // of size at least LAGRAPH_MAX_NAME_LEN).
+      65             :     // input:
+      66             :     GrB_Matrix A,   // matrix to query
+      67             :     char *msg
+      68             : )
+      69             : {
+      70             : 
+      71             :     //--------------------------------------------------------------------------
+      72             :     // check inputs
+      73             :     //--------------------------------------------------------------------------
+      74             : 
+      75       29367 :     LG_CLEAR_MSG ;
+      76       29367 :     LG_ASSERT (name != NULL, GrB_NULL_POINTER) ;
+      77             : 
+      78             :     //--------------------------------------------------------------------------
+      79             :     // determine the name of the type of the GrB_Matrix A
+      80             :     //--------------------------------------------------------------------------
+      81             : 
+      82             :     #if 1 // LAGRAPH_SUITESPARSE
+      83       29367 :     return (GxB_Matrix_type_name (name, A)) ;
+      84             :     #else
+      85             :     name [0] = '\0' ;
+      86             :     return (GrB_NOT_IMPLEMENTED) ;
+      87             :     #endif
+      88             : }
+      89             : 
+      90             : //------------------------------------------------------------------------------
+      91             : // LAGraph_Vector_TypeName: return the name of the GrB_Type of a GrB_Vector
+      92             : //------------------------------------------------------------------------------
+      93             : 
+      94       25383 : int LAGraph_Vector_TypeName
+      95             : (
+      96             :     // output:
+      97             :     char *name,     // name of the type of the vector v (user-provided array
+      98             :                     // of size at least LAGRAPH_MAX_NAME_LEN).
+      99             :     // input:
+     100             :     GrB_Vector v,   // vector to query
+     101             :     char *msg
+     102             : )
+     103             : {
+     104             : 
+     105             :     //--------------------------------------------------------------------------
+     106             :     // check inputs
+     107             :     //--------------------------------------------------------------------------
+     108             : 
+     109       25383 :     LG_CLEAR_MSG ;
+     110       25383 :     LG_ASSERT (name != NULL, GrB_NULL_POINTER) ;
+     111             : 
+     112             :     //--------------------------------------------------------------------------
+     113             :     // determine the name of the type of the GrB_Vector v
+     114             :     //--------------------------------------------------------------------------
+     115             : 
+     116             :     #if 1 // LAGRAPH_SUITESPARSE
+     117       25383 :     return (GxB_Vector_type_name (name, v)) ;
+     118             :     #else
+     119             :     name [0] = '\0' ;
+     120             :     return (GrB_NOT_IMPLEMENTED) ;
+     121             :     #endif
+     122             : }
+     123             : 
+     124             : //------------------------------------------------------------------------------
+     125             : // LAGraph_Scalar_TypeName: return the name of the GrB_Type of a GrB_Scalar
+     126             : //------------------------------------------------------------------------------
+     127             : 
+     128           3 : int LAGraph_Scalar_TypeName
+     129             : (
+     130             :     // output:
+     131             :     char *name,     // name of the type of the scalar s (user-provided array
+     132             :                     // of size at least LAGRAPH_MAX_NAME_LEN).
+     133             :     // input:
+     134             :     GrB_Scalar s,   // scalar to query
+     135             :     char *msg
+     136             : )
+     137             : {
+     138             : 
+     139             :     //--------------------------------------------------------------------------
+     140             :     // check inputs
+     141             :     //--------------------------------------------------------------------------
+     142             : 
+     143           3 :     LG_CLEAR_MSG ;
+     144           3 :     LG_ASSERT (name != NULL, GrB_NULL_POINTER) ;
+     145             : 
+     146             :     //--------------------------------------------------------------------------
+     147             :     // determine the name of the type of the GrB_Scalar s
+     148             :     //--------------------------------------------------------------------------
+     149             : 
+     150             :     #if 1 // LAGRAPH_SUITESPARSE
+     151           2 :     return (GxB_Scalar_type_name (name, s)) ;
+     152             :     #else
+     153             :     name [0] = '\0' ;
+     154             :     return (GrB_NOT_IMPLEMENTED) ;
+     155             :     #endif
+     156             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Vector_IsEqual.c.func-sort-c.html b/src/utility/LAGraph_Vector_IsEqual.c.func-sort-c.html new file mode 100644 index 0000000000..100f09fc3a --- /dev/null +++ b/src/utility/LAGraph_Vector_IsEqual.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Vector_IsEqual.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Vector_IsEqual.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:4646100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_Vector_IsEqual625
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Vector_IsEqual.c.func.html b/src/utility/LAGraph_Vector_IsEqual.c.func.html new file mode 100644 index 0000000000..0586e7442c --- /dev/null +++ b/src/utility/LAGraph_Vector_IsEqual.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Vector_IsEqual.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Vector_IsEqual.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:4646100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_Vector_IsEqual625
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Vector_IsEqual.c.gcov.html b/src/utility/LAGraph_Vector_IsEqual.c.gcov.html new file mode 100644 index 0000000000..1d0975684f --- /dev/null +++ b/src/utility/LAGraph_Vector_IsEqual.c.gcov.html @@ -0,0 +1,241 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Vector_IsEqual.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Vector_IsEqual.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:4646100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_Vector_IsEqual: check two vectors for exact equality
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // LAGraph_Vector_IsEqual: checks if two vectors are identically equal (same
+      19             : // size, type, structure, size, and values).
+      20             : 
+      21             : // See also LAGraph_Matrix_IsEqual.
+      22             : 
+      23             : // If the two vectors are GrB_FP32, GrB_FP64, or related, and have NaNs, then
+      24             : // this function will return false, since NaN == NaN is false.  To check for
+      25             : // NaN equality (like isequalwithequalnans in MATLAB), use
+      26             : // LAGraph_Vector_IsEqualOp with a user-defined operator f(x,y) that returns
+      27             : // true if x and y are both NaN.
+      28             : 
+      29             : #define LG_FREE_WORK GrB_free (&C) ;
+      30             : 
+      31             : #include "LG_internal.h"
+      32             : 
+      33         625 : int LAGraph_Vector_IsEqual
+      34             : (
+      35             :     // output:
+      36             :     bool *result,           // true if A == B, false if A != B or error
+      37             :     // input:
+      38             :     const GrB_Vector A,
+      39             :     const GrB_Vector B,
+      40             :     char *msg
+      41             : )
+      42             : {
+      43             : 
+      44             :     //--------------------------------------------------------------------------
+      45             :     // check inputs
+      46             :     //--------------------------------------------------------------------------
+      47             : 
+      48         625 :     LG_CLEAR_MSG ;
+      49         625 :     GrB_Vector C = NULL ;
+      50         625 :     LG_ASSERT (result != NULL, GrB_NULL_POINTER) ;
+      51             : 
+      52             :     //--------------------------------------------------------------------------
+      53             :     // check for NULL and aliased vectors
+      54             :     //--------------------------------------------------------------------------
+      55             : 
+      56         624 :     if (A == NULL || B == NULL || A == B)
+      57             :     {
+      58             :         // two NULL vectors are identical, as are two aliased matrices
+      59          65 :         (*result) = (A == B) ;
+      60          65 :         return (GrB_SUCCESS) ;
+      61             :     }
+      62             : 
+      63             :     //--------------------------------------------------------------------------
+      64             :     // compare the type of A and B
+      65             :     //--------------------------------------------------------------------------
+      66             : 
+      67             :     char atype_name [LAGRAPH_MAX_NAME_LEN] ;
+      68             :     char btype_name [LAGRAPH_MAX_NAME_LEN] ;
+      69         559 :     LG_TRY (LAGraph_Vector_TypeName (atype_name, A, msg)) ;
+      70         559 :     LG_TRY (LAGraph_Vector_TypeName (btype_name, B, msg)) ;
+      71         559 :     if (!MATCHNAME (atype_name, btype_name))
+      72             :     {
+      73             :         // types differ
+      74           1 :         (*result) = false ;
+      75           1 :         return (GrB_SUCCESS) ;
+      76             :     }
+      77             : 
+      78             :     //--------------------------------------------------------------------------
+      79             :     // compare the size of A and B
+      80             :     //--------------------------------------------------------------------------
+      81             : 
+      82             :     GrB_Index nrows1, nrows2;
+      83         558 :     GRB_TRY (GrB_Vector_size (&nrows1, A)) ;
+      84         558 :     GRB_TRY (GrB_Vector_size (&nrows2, B)) ;
+      85         558 :     if (nrows1 != nrows2)
+      86             :     {
+      87             :         // # of rows differ
+      88           4 :         (*result) = false ;
+      89           4 :         return (GrB_SUCCESS) ;
+      90             :     }
+      91             : 
+      92             :     //--------------------------------------------------------------------------
+      93             :     // compare the # entries in A and B
+      94             :     //--------------------------------------------------------------------------
+      95             : 
+      96             :     GrB_Index nvals1, nvals2 ;
+      97         554 :     GRB_TRY (GrB_Vector_nvals (&nvals1, A)) ;
+      98         554 :     GRB_TRY (GrB_Vector_nvals (&nvals2, B)) ;
+      99         554 :     if (nvals1 != nvals2)
+     100             :     {
+     101             :         // # of entries differ
+     102          78 :         (*result) = false ;
+     103          78 :         return (GrB_SUCCESS) ;
+     104             :     }
+     105             : 
+     106             :     //--------------------------------------------------------------------------
+     107             :     // get the GrB_EQ_type operator
+     108             :     //--------------------------------------------------------------------------
+     109             : 
+     110             :     GrB_Type type ;
+     111         476 :     LG_TRY (LAGraph_TypeFromName (&type, atype_name, msg)) ;
+     112         476 :     GrB_BinaryOp op = NULL ;
+     113             :     // select the comparator operator
+     114         476 :     if      (type == GrB_BOOL  ) op = GrB_EQ_BOOL   ;
+     115         462 :     else if (type == GrB_INT8  ) op = GrB_EQ_INT8   ;
+     116         462 :     else if (type == GrB_INT16 ) op = GrB_EQ_INT16  ;
+     117         462 :     else if (type == GrB_INT32 ) op = GrB_EQ_INT32  ;
+     118         422 :     else if (type == GrB_INT64 ) op = GrB_EQ_INT64  ;
+     119         422 :     else if (type == GrB_UINT8 ) op = GrB_EQ_UINT8  ;
+     120         422 :     else if (type == GrB_UINT16) op = GrB_EQ_UINT16 ;
+     121         422 :     else if (type == GrB_UINT32) op = GrB_EQ_UINT32 ;
+     122         422 :     else if (type == GrB_UINT64) op = GrB_EQ_UINT64 ;
+     123         420 :     else if (type == GrB_FP32  ) op = GrB_EQ_FP32   ;
+     124         420 :     else if (type == GrB_FP64  ) op = GrB_EQ_FP64   ;
+     125             :     #if 0
+     126             :     else if (type == GxB_FC32  ) op = GxB_EQ_FC32   ;
+     127             :     else if (type == GxB_FC64  ) op = GxB_EQ_FC64   ;
+     128             :     #endif
+     129             : 
+     130         476 :     LG_ASSERT_MSG (op != NULL, GrB_NOT_IMPLEMENTED, "type not supported") ;
+     131             : 
+     132             :     //--------------------------------------------------------------------------
+     133             :     // C = A .* B, where the structure of C is the intersection of A and B
+     134             :     //--------------------------------------------------------------------------
+     135             : 
+     136         476 :     GRB_TRY (GrB_Vector_new (&C, GrB_BOOL, nrows1)) ;
+     137         452 :     GRB_TRY (GrB_eWiseMult (C, NULL, NULL, op, A, B, NULL)) ;
+     138             : 
+     139             :     //--------------------------------------------------------------------------
+     140             :     // ensure C has the same number of entries as A and B
+     141             :     //--------------------------------------------------------------------------
+     142             : 
+     143             :     GrB_Index nvals ;
+     144         429 :     GRB_TRY (GrB_Vector_nvals (&nvals, C)) ;
+     145         429 :     if (nvals != nvals1)
+     146             :     {
+     147             :         // structure of A and B are different
+     148           1 :         LG_FREE_WORK ;
+     149           1 :         (*result) = false ;
+     150           1 :         return (GrB_SUCCESS) ;
+     151             :     }
+     152             : 
+     153             :     //--------------------------------------------------------------------------
+     154             :     // result = and (C)
+     155             :     //--------------------------------------------------------------------------
+     156             : 
+     157         428 :     GRB_TRY (GrB_reduce (result, NULL, GrB_LAND_MONOID_BOOL, C, NULL)) ;
+     158             : 
+     159             :     //--------------------------------------------------------------------------
+     160             :     // free workspace and return result
+     161             :     //--------------------------------------------------------------------------
+     162             : 
+     163         428 :     LG_FREE_WORK ;
+     164         428 :     return (GrB_SUCCESS) ;
+     165             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Vector_IsEqualOp.c.func-sort-c.html b/src/utility/LAGraph_Vector_IsEqualOp.c.func-sort-c.html new file mode 100644 index 0000000000..93d6d7ff71 --- /dev/null +++ b/src/utility/LAGraph_Vector_IsEqualOp.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Vector_IsEqualOp.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Vector_IsEqualOp.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:2727100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_Vector_IsEqualOp275
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Vector_IsEqualOp.c.func.html b/src/utility/LAGraph_Vector_IsEqualOp.c.func.html new file mode 100644 index 0000000000..6d80c2dc0f --- /dev/null +++ b/src/utility/LAGraph_Vector_IsEqualOp.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Vector_IsEqualOp.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Vector_IsEqualOp.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:2727100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_Vector_IsEqualOp275
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Vector_IsEqualOp.c.gcov.html b/src/utility/LAGraph_Vector_IsEqualOp.c.gcov.html new file mode 100644 index 0000000000..8c01dae006 --- /dev/null +++ b/src/utility/LAGraph_Vector_IsEqualOp.c.gcov.html @@ -0,0 +1,199 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Vector_IsEqualOp.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Vector_IsEqualOp.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:2727100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_Vector_IsEqualOp: compare two vectors with a given op
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // LAGraph_Vector_IsEqualOp: checks if two vectors are equal (same size,
+      19             : // structure, size, and values), using a provided binary operator.
+      20             : 
+      21             : // See also LAGraph_Matrix_IsEqualOp.
+      22             : 
+      23             : #define LG_FREE_WORK GrB_free (&C) ;
+      24             : 
+      25             : #include "LG_internal.h"
+      26             : 
+      27             : //------------------------------------------------------------------------------
+      28             : // LAGraph_Vector_IsEqualOp:  compare two vectors using a given operator
+      29             : //------------------------------------------------------------------------------
+      30             : 
+      31         275 : int LAGraph_Vector_IsEqualOp
+      32             : (
+      33             :     // output:
+      34             :     bool *result,           // true if A == B, false if A != B or error
+      35             :     // input:
+      36             :     const GrB_Vector A,
+      37             :     const GrB_Vector B,
+      38             :     const GrB_BinaryOp op,        // comparator to use
+      39             :     char *msg
+      40             : )
+      41             : {
+      42             : 
+      43             :     //--------------------------------------------------------------------------
+      44             :     // check inputs
+      45             :     //--------------------------------------------------------------------------
+      46             : 
+      47         275 :     LG_CLEAR_MSG ;
+      48         275 :     GrB_Vector C = NULL ;
+      49         275 :     LG_ASSERT (op != NULL && result != NULL, GrB_NULL_POINTER) ;
+      50             : 
+      51             :     //--------------------------------------------------------------------------
+      52             :     // check for NULL and aliased vectors
+      53             :     //--------------------------------------------------------------------------
+      54             : 
+      55         274 :     if (A == NULL || B == NULL || A == B)
+      56             :     {
+      57             :         // two NULL vectors are identical, as are two aliased matrices
+      58           1 :         (*result) = (A == B) ;
+      59           1 :         return (GrB_SUCCESS) ;
+      60             :     }
+      61             : 
+      62             :     //--------------------------------------------------------------------------
+      63             :     // compare the size of A and B
+      64             :     //--------------------------------------------------------------------------
+      65             : 
+      66             :     GrB_Index nrows1, nrows2;
+      67         273 :     GRB_TRY (GrB_Vector_size (&nrows1, A)) ;
+      68         273 :     GRB_TRY (GrB_Vector_size (&nrows2, B)) ;
+      69         273 :     if (nrows1 != nrows2)
+      70             :     {
+      71             :         // # of rows differ
+      72           1 :         (*result) = false ;
+      73           1 :         return (GrB_SUCCESS) ;
+      74             :     }
+      75             : 
+      76             :     //--------------------------------------------------------------------------
+      77             :     // compare the # entries in A and B
+      78             :     //--------------------------------------------------------------------------
+      79             : 
+      80             :     GrB_Index nvals1, nvals2 ;
+      81         272 :     GRB_TRY (GrB_Vector_nvals (&nvals1, A)) ;
+      82         272 :     GRB_TRY (GrB_Vector_nvals (&nvals2, B)) ;
+      83         272 :     if (nvals1 != nvals2)
+      84             :     {
+      85             :         // # of entries differ
+      86          57 :         (*result) = false ;
+      87          57 :         return (GrB_SUCCESS) ;
+      88             :     }
+      89             : 
+      90             :     //--------------------------------------------------------------------------
+      91             :     // C = A .* B, where the structure of C is the intersection of A and B
+      92             :     //--------------------------------------------------------------------------
+      93             : 
+      94         215 :     GRB_TRY (GrB_Vector_new (&C, GrB_BOOL, nrows1)) ;
+      95         215 :     GRB_TRY (GrB_eWiseMult (C, NULL, NULL, op, A, B, NULL)) ;
+      96             : 
+      97             :     //--------------------------------------------------------------------------
+      98             :     // ensure C has the same number of entries as A and B
+      99             :     //--------------------------------------------------------------------------
+     100             : 
+     101             :     GrB_Index nvals ;
+     102         215 :     GRB_TRY (GrB_Vector_nvals (&nvals, C)) ;
+     103         215 :     if (nvals != nvals1)
+     104             :     {
+     105             :         // structure of A and B are different
+     106           1 :         LG_FREE_WORK ;
+     107           1 :         (*result) = false ;
+     108           1 :         return (GrB_SUCCESS) ;
+     109             :     }
+     110             : 
+     111             :     //--------------------------------------------------------------------------
+     112             :     // result = and (C)
+     113             :     //--------------------------------------------------------------------------
+     114             : 
+     115         214 :     GRB_TRY (GrB_reduce (result, NULL, GrB_LAND_MONOID_BOOL, C, NULL)) ;
+     116             : 
+     117             :     //--------------------------------------------------------------------------
+     118             :     // free workspace and return result
+     119             :     //--------------------------------------------------------------------------
+     120             : 
+     121         214 :     LG_FREE_WORK ;
+     122         214 :     return (GrB_SUCCESS) ;
+     123             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Vector_Print.c.func-sort-c.html b/src/utility/LAGraph_Vector_Print.c.func-sort-c.html new file mode 100644 index 0000000000..96d986a25d --- /dev/null +++ b/src/utility/LAGraph_Vector_Print.c.func-sort-c.html @@ -0,0 +1,120 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Vector_Print.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Vector_Print.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:4040100.0 %
Date:2024-08-29 20:08:04Functions:1212100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_Vector_Print_INT164
LG_Vector_Print_INT84
LG_Vector_Print_UINT164
LG_Vector_Print_UINT84
LG_Vector_Print_FP326
LG_Vector_Print_BOOL8
LG_Vector_Print_UINT3223
LG_Vector_Print_INT3233
LG_Vector_Print_FP6452
LG_Vector_Print_UINT6495
LG_Vector_Print_INT64317
LAGraph_Vector_Print552
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Vector_Print.c.func.html b/src/utility/LAGraph_Vector_Print.c.func.html new file mode 100644 index 0000000000..ad799742f2 --- /dev/null +++ b/src/utility/LAGraph_Vector_Print.c.func.html @@ -0,0 +1,120 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Vector_Print.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Vector_Print.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:4040100.0 %
Date:2024-08-29 20:08:04Functions:1212100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_Vector_Print552
LG_Vector_Print_BOOL8
LG_Vector_Print_FP326
LG_Vector_Print_FP6452
LG_Vector_Print_INT164
LG_Vector_Print_INT3233
LG_Vector_Print_INT64317
LG_Vector_Print_INT84
LG_Vector_Print_UINT164
LG_Vector_Print_UINT3223
LG_Vector_Print_UINT6495
LG_Vector_Print_UINT84
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Vector_Print.c.gcov.html b/src/utility/LAGraph_Vector_Print.c.gcov.html new file mode 100644 index 0000000000..a7fb8ff25c --- /dev/null +++ b/src/utility/LAGraph_Vector_Print.c.gcov.html @@ -0,0 +1,282 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Vector_Print.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Vector_Print.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:4040100.0 %
Date:2024-08-29 20:08:04Functions:1212100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_Vector_Print:  pretty-print a vector
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // LAGraph_Vector_Print:  pretty-print a vector.  The type is either derived
+      19             : // from GxB_Vector_type (if available) or assumed to be GrB_FP64 otherwise,
+      20             : // or passed in as a parameter.
+      21             : 
+      22             : #include "LG_internal.h"
+      23             : 
+      24             : #undef  LG_FREE_WORK
+      25             : #define LG_FREE_WORK                    \
+      26             : {                                       \
+      27             :     LAGraph_Free ((void **) &I, NULL) ; \
+      28             :     LAGraph_Free ((void **) &X, NULL) ; \
+      29             : }
+      30             : 
+      31             : #undef  LG_FREE_ALL
+      32             : #define LG_FREE_ALL LG_FREE_WORK
+      33             : 
+      34             : //------------------------------------------------------------------------------
+      35             : // LG_Vector_Print_TYPE: print with the specified type
+      36             : //------------------------------------------------------------------------------
+      37             : 
+      38             : #define LG_VECTOR_PRINT(suffix,ctype,gtype,fmt1,fmt2)                       \
+      39             : int LG_Vector_Print_ ## suffix                                              \
+      40             : (                                                                           \
+      41             :     GrB_Vector v, LAGraph_PrintLevel pr, FILE *f, char *msg                 \
+      42             : )                                                                           \
+      43             : {                                                                           \
+      44             :     LG_CLEAR_MSG ;                                                          \
+      45             :     ctype *X = NULL ;                                                       \
+      46             :     GrB_Index *I = NULL ;                                                   \
+      47             :     LG_ASSERT (v != NULL, GrB_NULL_POINTER) ;                               \
+      48             :     LG_ASSERT (f != NULL, GrB_NULL_POINTER) ;                               \
+      49             :     int prl = (int) pr ;                                                    \
+      50             :     if (prl <= 0) return (GrB_SUCCESS) ;                                    \
+      51             :     /* get basic properties */                                              \
+      52             :     GrB_Index n, nvals ;                                                    \
+      53             :     GRB_TRY (GrB_Vector_size  (&n, v)) ;                                    \
+      54             :     GRB_TRY (GrB_Vector_nvals (&nvals, v)) ;                                \
+      55             :     /* print header line */                                                 \
+      56             :     FPRINTF (f, "%s vector: n: %" PRIu64 " entries: %" PRIu64               \
+      57             :         "\n", LG_XSTR (gtype), n, nvals) ;                                  \
+      58             :     if (prl <= 1) return (GrB_SUCCESS) ;                                    \
+      59             :     /* extract tuples */                                                    \
+      60             :     LG_TRY (LAGraph_Malloc ((void **) &I, nvals, sizeof (GrB_Index), msg)) ;\
+      61             :     LG_TRY (LAGraph_Malloc ((void **) &X, nvals, sizeof (ctype), msg)) ;    \
+      62             :     GrB_Info info = GrB_Vector_extractTuples (I, X, &nvals, v) ;            \
+      63             :     LG_ASSERT_MSG (info != GrB_DOMAIN_MISMATCH,                             \
+      64             :         GrB_NOT_IMPLEMENTED, "type not supported") ;                        \
+      65             :     GRB_TRY (info) ;                                                        \
+      66             :     /* determine the format */                                              \
+      67             :     char *format = (prl <= 3) ? fmt1 : fmt2 ;                               \
+      68             :     bool summary = (prl == 2 || prl == 4) && (nvals > LG_SHORT_LEN) ;       \
+      69             :     for (int64_t k = 0 ; k < nvals ; k++)                                   \
+      70             :     {                                                                       \
+      71             :         /* print the kth tuple */                                           \
+      72             :         GrB_Index i = I [k] ;                                               \
+      73             :         ctype     x = X [k] ;                                               \
+      74             :         FPRINTF (f, "    (%" PRIu64 ")   ", i) ;                            \
+      75             :         FPRINTF (f, format, x) ;                                            \
+      76             :         FPRINTF (f, "\n") ;                                                 \
+      77             :         if (summary && k > LG_SHORT_LEN)                                    \
+      78             :         {                                                                   \
+      79             :             /* quit early if a only a summary is requested */               \
+      80             :             FPRINTF (f, "    ...\n") ;                                      \
+      81             :             break ;                                                         \
+      82             :         }                                                                   \
+      83             :     }                                                                       \
+      84             :     LG_FREE_WORK ;                                                          \
+      85             :     return (GrB_SUCCESS) ;                                                  \
+      86             : }
+      87             : 
+      88         114 : LG_VECTOR_PRINT (BOOL  , bool    , GrB_BOOL  , "%d"  , "%d"    ) ;
+      89          66 : LG_VECTOR_PRINT (INT8  , int8_t  , GrB_INT8  , "%d"  , "%d"    ) ;
+      90          66 : LG_VECTOR_PRINT (INT16 , int16_t , GrB_INT16 , "%d"  , "%d"    ) ;
+      91         553 : LG_VECTOR_PRINT (INT32 , int32_t , GrB_INT32 , "%" PRId32, "%" PRId32  ) ;
+      92        3317 : LG_VECTOR_PRINT (INT64 , int64_t , GrB_INT64 , "%" PRId64, "%" PRId64  ) ;
+      93          66 : LG_VECTOR_PRINT (UINT8 , uint8_t , GrB_UINT8 , "%d"  , "%d"    ) ;
+      94          66 : LG_VECTOR_PRINT (UINT16, uint16_t, GrB_UINT16, "%d"  , "%d"    ) ;
+      95         339 : LG_VECTOR_PRINT (UINT32, uint32_t, GrB_UINT32, "%" PRIu32, "%" PRIu32  ) ;
+      96        1594 : LG_VECTOR_PRINT (UINT64, uint64_t, GrB_UINT64, "%" PRIu64, "%" PRIu64  ) ;
+      97          88 : LG_VECTOR_PRINT (FP32  , float   , GrB_FP32  , "%g"  , "%0.7g" ) ;
+      98         980 : LG_VECTOR_PRINT (FP64  , double  , GrB_FP64  , "%g"  , "%0.15g") ;
+      99             : #if 0
+     100             : // would need to pass in an iscomplex flag to print creal(x) and cimag(x)
+     101             : LG_VECTOR_PRINT (FC32  , GxB_FC32_t, GxB_FC32, ...) ;
+     102             : LG_VECTOR_PRINT (FC64  , GxB_FC64_t, GxB_FC64, ...) ;
+     103             : #endif
+     104             : 
+     105             : #undef  LG_FREE_WORK
+     106             : #define LG_FREE_WORK ;
+     107             : #undef  LG_FREE_ALL
+     108             : #define LG_FREE_ALL ;
+     109             : 
+     110             : //------------------------------------------------------------------------------
+     111             : // LAGraph_Vector_Print: automatically determine the type
+     112             : //------------------------------------------------------------------------------
+     113             : 
+     114         552 : int LAGraph_Vector_Print
+     115             : (
+     116             :     // input:
+     117             :     const GrB_Vector v,     // vector to pretty-print to the file
+     118             :     LAGraph_PrintLevel pr,  // print level (0 to 5)
+     119             :     FILE *f,            // file to write it to, must be already open; use
+     120             :                         // stdout or stderr to print to those locations.
+     121             :     char *msg
+     122             : )
+     123             : {
+     124             : 
+     125             :     //--------------------------------------------------------------------------
+     126             :     // check inputs
+     127             :     //--------------------------------------------------------------------------
+     128             : 
+     129         552 :     LG_CLEAR_MSG ;
+     130         552 :     LG_ASSERT (v != NULL, GrB_NULL_POINTER) ;
+     131         552 :     LG_ASSERT (f != NULL, GrB_NULL_POINTER) ;
+     132             : 
+     133             :     //--------------------------------------------------------------------------
+     134             :     // determine the type
+     135             :     //--------------------------------------------------------------------------
+     136             : 
+     137             :     GrB_Type type ;
+     138             :     char typename [LAGRAPH_MAX_NAME_LEN] ;
+     139         551 :     LG_TRY (LAGraph_Vector_TypeName (typename, v, msg)) ;
+     140         551 :     LG_TRY (LAGraph_TypeFromName (&type, typename, msg)) ;
+     141             : 
+     142             :     //--------------------------------------------------------------------------
+     143             :     // print the vector
+     144             :     //--------------------------------------------------------------------------
+     145             : 
+     146         551 :     if (type == GrB_BOOL)
+     147             :     {
+     148           8 :         return (LG_Vector_Print_BOOL (v, pr, f, msg)) ;
+     149             :     }
+     150         543 :     else if (type == GrB_INT8)
+     151             :     {
+     152           4 :         return (LG_Vector_Print_INT8 (v, pr, f, msg)) ;
+     153             :     }
+     154         539 :     else if (type == GrB_INT16)
+     155             :     {
+     156           4 :         return (LG_Vector_Print_INT16 (v, pr, f, msg)) ;
+     157             :     }
+     158         535 :     else if (type == GrB_INT32)
+     159             :     {
+     160          33 :         return (LG_Vector_Print_INT32 (v, pr, f, msg)) ;
+     161             :     }
+     162         502 :     else if (type == GrB_INT64)
+     163             :     {
+     164         317 :         return (LG_Vector_Print_INT64 (v, pr, f, msg)) ;
+     165             :     }
+     166         185 :     else if (type == GrB_UINT8)
+     167             :     {
+     168           4 :         return (LG_Vector_Print_UINT8 (v, pr, f, msg)) ;
+     169             :     }
+     170         181 :     else if (type == GrB_UINT16)
+     171             :     {
+     172           4 :         return (LG_Vector_Print_UINT16 (v, pr, f, msg)) ;
+     173             :     }
+     174         177 :     else if (type == GrB_UINT32)
+     175             :     {
+     176          23 :         return (LG_Vector_Print_UINT32 (v, pr, f, msg)) ;
+     177             :     }
+     178         154 :     else if (type == GrB_UINT64)
+     179             :     {
+     180          95 :         return (LG_Vector_Print_UINT64 (v, pr, f, msg)) ;
+     181             :     }
+     182          59 :     else if (type == GrB_FP32)
+     183             :     {
+     184           6 :         return (LG_Vector_Print_FP32 (v, pr, f, msg)) ;
+     185             :     }
+     186          53 :     else if (type == GrB_FP64)
+     187             :     {
+     188          52 :         return (LG_Vector_Print_FP64 (v, pr, f, msg)) ;
+     189             :     }
+     190             :     #if 0
+     191             :     else if (type == GxB_FC32)
+     192             :     {
+     193             :         return (LG_Vector_Print_FC32 (v, pr, f, msg)) ;
+     194             :     }
+     195             :     else if (type == GxB_FC32)
+     196             :     {
+     197             :         return (LG_Vector_Print_FC64 (v, pr, f, msg)) ;
+     198             :     }
+     199             :     #endif
+     200             :     else
+     201             :     {
+     202           1 :         LG_ASSERT_MSG (false,
+     203             :             GrB_NOT_IMPLEMENTED, "user-defined types not supported") ;
+     204             :         return (GrB_SUCCESS) ;
+     205             :     }
+     206             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Vector_Structure.c.func-sort-c.html b/src/utility/LAGraph_Vector_Structure.c.func-sort-c.html new file mode 100644 index 0000000000..048b4c6ec4 --- /dev/null +++ b/src/utility/LAGraph_Vector_Structure.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Vector_Structure.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Vector_Structure.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:99100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_Vector_Structure4
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Vector_Structure.c.func.html b/src/utility/LAGraph_Vector_Structure.c.func.html new file mode 100644 index 0000000000..a583af327f --- /dev/null +++ b/src/utility/LAGraph_Vector_Structure.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Vector_Structure.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Vector_Structure.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:99100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_Vector_Structure4
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Vector_Structure.c.gcov.html b/src/utility/LAGraph_Vector_Structure.c.gcov.html new file mode 100644 index 0000000000..06060db319 --- /dev/null +++ b/src/utility/LAGraph_Vector_Structure.c.gcov.html @@ -0,0 +1,137 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Vector_Structure.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Vector_Structure.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:99100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_Vector_Structure: return the structure of a vector
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // LAGraph_Vector_Structure: return the structure of a vector as a boolean
+      19             : // vector, where w(i)=true if the entry u(i) is present in the vector u.
+      20             : 
+      21             : #define LG_FREE_ALL GrB_free (w) ;
+      22             : 
+      23             : #include "LG_internal.h"
+      24             : 
+      25           4 : int LAGraph_Vector_Structure
+      26             : (
+      27             :     // output:
+      28             :     GrB_Vector *w,  // a boolean matrix with same structure of u, with w(i)
+      29             :                     // set to true if u(i) appears in the sparsity structure
+      30             :                     // of u.
+      31             :     // input:
+      32             :     GrB_Vector u,
+      33             :     char *msg
+      34             : )
+      35             : {
+      36             : 
+      37             :     //--------------------------------------------------------------------------
+      38             :     // check inputs
+      39             :     //--------------------------------------------------------------------------
+      40             : 
+      41           4 :     LG_CLEAR_MSG ;
+      42             :     GrB_Index n ;
+      43           4 :     LG_ASSERT_MSG (w != NULL, GrB_NULL_POINTER, "&w != NULL") ;
+      44           3 :     LG_ASSERT (u != NULL, GrB_NULL_POINTER) ;
+      45           2 :     (*w) = NULL ;
+      46             : 
+      47             :     //--------------------------------------------------------------------------
+      48             :     // get the size of u
+      49             :     //--------------------------------------------------------------------------
+      50             : 
+      51           2 :     GRB_TRY (GrB_Vector_size (&n, u)) ;
+      52             : 
+      53             :     //--------------------------------------------------------------------------
+      54             :     // w<s(u)> = true
+      55             :     //--------------------------------------------------------------------------
+      56             : 
+      57           2 :     GRB_TRY (GrB_Vector_new (w, GrB_BOOL, n)) ;
+      58           2 :     GRB_TRY (GrB_assign (*w, u, NULL, (bool) true, GrB_ALL, n, GrB_DESC_S)) ;
+      59             : 
+      60           2 :     return (GrB_SUCCESS) ;
+      61             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Version.c.func-sort-c.html b/src/utility/LAGraph_Version.c.func-sort-c.html new file mode 100644 index 0000000000..d4b835d9fc --- /dev/null +++ b/src/utility/LAGraph_Version.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Version.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Version.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:99100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_Version1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Version.c.func.html b/src/utility/LAGraph_Version.c.func.html new file mode 100644 index 0000000000..d051cd84ae --- /dev/null +++ b/src/utility/LAGraph_Version.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Version.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Version.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:99100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_Version1
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_Version.c.gcov.html b/src/utility/LAGraph_Version.c.gcov.html new file mode 100644 index 0000000000..614801f1ac --- /dev/null +++ b/src/utility/LAGraph_Version.c.gcov.html @@ -0,0 +1,135 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_Version.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_Version.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:99100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_Version: return the LAGraph version number and date
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // The version number and date can also be obtained via compile-time constants
+      19             : // from LAGraph.h.  However, it is possible to compile a user application that
+      20             : // #includes one version of LAGraph.h and then links with another version of
+      21             : // the LAGraph library later on, so the version number and date may differ from
+      22             : // the compile-time constants.
+      23             : 
+      24             : // The LAGraph_Version method allows the library itself to be
+      25             : // queried, after it is linked in with the user application.
+      26             : 
+      27             : // The version_number array is set to LAGRAPH_VERSION_MAJOR,
+      28             : // LAGRAPH_VERSION_MINOR, and LAGRAPH_VERSION_UPDATE, in that order.
+      29             : // The LAGRAPH_DATE string is copied into the user-provided version_date
+      30             : // string, and is null-terminated.
+      31             : 
+      32             : #include "LG_internal.h"
+      33             : 
+      34           1 : int LAGraph_Version
+      35             : (
+      36             :     // output:
+      37             :     int version_number [3],     // user-provided array of size 3
+      38             :     char version_date [LAGRAPH_MSG_LEN],    // user-provided array
+      39             :     char *msg
+      40             : )
+      41             : {
+      42             : 
+      43           1 :     LG_CLEAR_MSG ;
+      44             : 
+      45             :     // check inputs
+      46           1 :     LG_ASSERT (version_number != NULL && version_date != NULL,
+      47             :         GrB_NULL_POINTER) ;
+      48             : 
+      49             :     // get version number and date
+      50           1 :     version_number [0] = LAGRAPH_VERSION_MAJOR ;
+      51           1 :     version_number [1] = LAGRAPH_VERSION_MINOR ;
+      52           1 :     version_number [2] = LAGRAPH_VERSION_UPDATE ;
+      53           1 :     strncpy (version_date, LAGRAPH_DATE, LAGRAPH_MSG_LEN) ;
+      54             : 
+      55             :     // make sure the date is null-terminated
+      56           1 :     version_date [LAGRAPH_MSG_LEN-1] = '\0' ;
+      57             : 
+      58           1 :     return (GrB_SUCCESS) ;
+      59             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_WallClockTime.c.func-sort-c.html b/src/utility/LAGraph_WallClockTime.c.func-sort-c.html new file mode 100644 index 0000000000..caa9198d50 --- /dev/null +++ b/src/utility/LAGraph_WallClockTime.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_WallClockTime.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_WallClockTime.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:66100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_WallClockTime3383
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_WallClockTime.c.func.html b/src/utility/LAGraph_WallClockTime.c.func.html new file mode 100644 index 0000000000..f71bac2f27 --- /dev/null +++ b/src/utility/LAGraph_WallClockTime.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_WallClockTime.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_WallClockTime.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:66100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LAGraph_WallClockTime3383
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LAGraph_WallClockTime.c.gcov.html b/src/utility/LAGraph_WallClockTime.c.gcov.html new file mode 100644 index 0000000000..6df89c6d8c --- /dev/null +++ b/src/utility/LAGraph_WallClockTime.c.gcov.html @@ -0,0 +1,169 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LAGraph_WallClockTime.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LAGraph_WallClockTime.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:66100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LAGraph_WallClockTime: return the current wall clock time
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // Unlike all other LAGraph functions, this function does not return an error
+      19             : // code as an int, nor does it have a char *msg parameter for error messages.
+      20             : // It simply returns the current wall clock time, as a double value, indicating
+      21             : // the amount of time passed in seconds since some fixed point in the past.
+      22             : 
+      23             : // Example usage:
+      24             : 
+      25             : /*
+      26             :     double t1 = LAGraph_WallClockTime ( ) ;
+      27             : 
+      28             :     // ... do stuff
+      29             :     double t2 = LAGraph_WallClockTime ( ) ;
+      30             :     printf ("time to 'do stuff' : %g (seconds)\n', t2 - t1) ;
+      31             :     // ... more stuff
+      32             :     double t3 = LAGraph_WallClockTime ( ) ;
+      33             :     printf ("time to 'do stuff' and 'more stuff': %g (seconds)\n', t3 - t1) ;
+      34             : */
+      35             : 
+      36             : #include "LG_internal.h"
+      37             : 
+      38             : #if !defined ( _OPENMP )
+      39             :     #include <time.h>
+      40             :     #if defined ( __linux__ ) || defined ( __GNU__ )
+      41             :         #include <sys/time.h>
+      42             :     #endif
+      43             :     #if defined ( __MACH__ ) && defined ( __APPLE__ )
+      44             :         #include <mach/clock.h>
+      45             :         #include <mach/mach.h>
+      46             :     #endif
+      47             : #endif
+      48             : 
+      49        3383 : double LAGraph_WallClockTime (void)
+      50             : {
+      51        3383 :     double t_wallclock = 0 ;
+      52             : 
+      53             :     #if defined ( _OPENMP )
+      54             : 
+      55             :         // OpenMP is available; use the OpenMP timer function
+      56             :         t_wallclock = omp_get_wtime ( ) ;
+      57             : 
+      58             :     #elif defined ( __linux__ )
+      59             : 
+      60             :         // Linux has a very low resolution clock() function, so use the high
+      61             :         // resolution clock_gettime instead.  May require -lrt
+      62             :         struct timespec t ;
+      63        3383 :         int e = clock_gettime (CLOCK_MONOTONIC, &t) ;
+      64        3383 :         if (e == 0)
+      65             :         {
+      66        3383 :             t_wallclock = (double) t.tv_sec + 1e-9 * ((double) t.tv_nsec) ;
+      67             :         }
+      68             : 
+      69             :     #elif defined ( __MACH__ )
+      70             : 
+      71             :         // Mac OSX
+      72             :         clock_serv_t cclock ;
+      73             :         mach_timespec_t t ;
+      74             :         host_get_clock_service (mach_host_self ( ), SYSTEM_CLOCK, &cclock) ;
+      75             :         clock_get_time (cclock, &t) ;
+      76             :         mach_port_deallocate (mach_task_self ( ), cclock) ;
+      77             :         t_wallclock = (double) t.tv_sec + 1e-9 * ((double) t.tv_nsec) ;
+      78             : 
+      79             :     #else
+      80             : 
+      81             :         // The ANSI C11 clock() function is used instead.  This gives the
+      82             :         // processor time, not the wallclock time, and it might have low
+      83             :         // resolution.  It returns the time since some unspecified fixed time
+      84             :         // in the past, as a clock_t integer.  The clock ticks per second are
+      85             :         // given by CLOCKS_PER_SEC.  In Mac OSX this is a very high resolution
+      86             :         // clock, and clock ( ) is faster than clock_get_time (...) ;
+      87             :         clock_t t = clock ( ) ;
+      88             :         t_wallclock = ((double) t) / ((double) CLOCKS_PER_SEC) ;
+      89             : 
+      90             :     #endif
+      91             : 
+      92        3383 :     return (t_wallclock) ;
+      93             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LG_KindName.c.func-sort-c.html b/src/utility/LG_KindName.c.func-sort-c.html new file mode 100644 index 0000000000..11ea7503a6 --- /dev/null +++ b/src/utility/LG_KindName.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LG_KindName.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LG_KindName.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:99100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_KindName334
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LG_KindName.c.func.html b/src/utility/LG_KindName.c.func.html new file mode 100644 index 0000000000..f3520ffbcf --- /dev/null +++ b/src/utility/LG_KindName.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LG_KindName.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LG_KindName.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:99100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_KindName334
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LG_KindName.c.gcov.html b/src/utility/LG_KindName.c.gcov.html new file mode 100644 index 0000000000..626d6d9a7c --- /dev/null +++ b/src/utility/LG_KindName.c.gcov.html @@ -0,0 +1,125 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LG_KindName.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LG_KindName.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:99100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LG_KindName: return the name of a kind
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include "LG_internal.h"
+      19             : 
+      20         334 : int LG_KindName
+      21             : (
+      22             :     char *name,     // name of the kind (user provided array of size at least
+      23             :                     // LAGRAPH_MAX_NAME_LEN)
+      24             :     LAGraph_Kind kind,  // graph kind
+      25             :     char *msg
+      26             : )
+      27             : {
+      28             : 
+      29             :     //--------------------------------------------------------------------------
+      30             :     // check inputs
+      31             :     //--------------------------------------------------------------------------
+      32             : 
+      33         334 :     LG_CLEAR_MSG ;
+      34         334 :     LG_ASSERT (name != NULL, GrB_NULL_POINTER) ;
+      35             : 
+      36             :     //--------------------------------------------------------------------------
+      37             :     // determine the name of the kind
+      38             :     //--------------------------------------------------------------------------
+      39             : 
+      40         334 :     switch (kind)
+      41             :     {
+      42          91 :         case LAGraph_ADJACENCY_UNDIRECTED : strcpy (name, "undirected"); break ;
+      43         241 :         case LAGraph_ADJACENCY_DIRECTED :   strcpy (name, "directed")  ; break ;
+      44           1 :         case LAGraph_KIND_UNKNOWN :         strcpy (name, "unknown")   ; break ;
+      45           1 :         default : LG_ASSERT_MSG (false, GrB_INVALID_VALUE, "invalid kind") ;
+      46             :     }
+      47             : 
+      48         333 :     return (GrB_SUCCESS) ;
+      49             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LG_Random.c.func-sort-c.html b/src/utility/LG_Random.c.func-sort-c.html new file mode 100644 index 0000000000..89989cac62 --- /dev/null +++ b/src/utility/LG_Random.c.func-sort-c.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LG_Random.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LG_Random.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1010100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_Random601768087
LG_Random1511273171
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LG_Random.c.func.html b/src/utility/LG_Random.c.func.html new file mode 100644 index 0000000000..c0b33adb4e --- /dev/null +++ b/src/utility/LG_Random.c.func.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LG_Random.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LG_Random.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1010100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_Random1511273171
LG_Random601768087
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LG_Random.c.gcov.html b/src/utility/LG_Random.c.gcov.html new file mode 100644 index 0000000000..94e6085550 --- /dev/null +++ b/src/utility/LG_Random.c.gcov.html @@ -0,0 +1,113 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LG_Random.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LG_Random.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1010100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LG_Random.c: simple and portable random number generator
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include "LG_internal.h"
+      19             : 
+      20             : // return a random number between 0 and LG_RANDOM15_MAX
+      21    11273171 : GrB_Index LG_Random15 (uint64_t *seed)
+      22             : {
+      23    11273171 :    (*seed) = (*seed) * 1103515245 + 12345 ;
+      24    11273171 :    return (((*seed) / 65536) % (LG_RANDOM15_MAX + 1)) ;
+      25             : }
+      26             : 
+      27             : // return a random uint64_t, in range 0 to LG_RANDOM60_MAX
+      28     1768087 : GrB_Index LG_Random60 (uint64_t *seed)
+      29             : {
+      30             :     GrB_Index i ;
+      31     1768087 :     i = LG_Random15 (seed) ;
+      32     1768087 :     i = LG_Random15 (seed) + LG_RANDOM15_MAX * i ;
+      33     1768087 :     i = LG_Random15 (seed) + LG_RANDOM15_MAX * i ;
+      34     1768087 :     i = LG_Random15 (seed) + LG_RANDOM15_MAX * i ;
+      35     1768087 :     i = i % (LG_RANDOM60_MAX + 1) ;
+      36     1768087 :     return (i) ;
+      37             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LG_internal.h.func-sort-c.html b/src/utility/LG_internal.h.func-sort-c.html new file mode 100644 index 0000000000..6915fe19be --- /dev/null +++ b/src/utility/LG_internal.h.func-sort-c.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LG_internal.h - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LG_internal.h (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1616100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_eslice12
LG_Multiply_size_t29649
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LG_internal.h.func.html b/src/utility/LG_internal.h.func.html new file mode 100644 index 0000000000..eb5d36ef2b --- /dev/null +++ b/src/utility/LG_internal.h.func.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LG_internal.h - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LG_internal.h (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1616100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_Multiply_size_t29649
LG_eslice12
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LG_internal.h.gcov.html b/src/utility/LG_internal.h.gcov.html new file mode 100644 index 0000000000..f15f2d00b4 --- /dev/null +++ b/src/utility/LG_internal.h.gcov.html @@ -0,0 +1,698 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LG_internal.h + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LG_internal.h (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1616100.0 %
Date:2024-08-29 20:08:04Functions:22100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LG_internal.h: include file for use within LAGraph itself
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // These definitions are not meant for the user application that relies on
+      19             : // LAGraph and/or GraphBLAS.  LG_* methods are for internal use in LAGraph.
+      20             : 
+      21             : #ifndef LG_INTERNAL_H
+      22             : #define LG_INTERNAL_H
+      23             : 
+      24             : //------------------------------------------------------------------------------
+      25             : // include files
+      26             : //------------------------------------------------------------------------------
+      27             : 
+      28             : #include <ctype.h>
+      29             : #include "LAGraph.h"
+      30             : #undef I
+      31             : 
+      32             : #if defined ( __linux__ )
+      33             : #include <malloc.h>
+      34             : #endif
+      35             : 
+      36             : #define LG_RESTRICT LAGRAPH_RESTRICT
+      37             : 
+      38             : //------------------------------------------------------------------------------
+      39             : // string macros
+      40             : //------------------------------------------------------------------------------
+      41             : 
+      42             : #define LG_XSTR(x) LG_STR(x)
+      43             : #define LG_STR(x) #x
+      44             : 
+      45             : //------------------------------------------------------------------------------
+      46             : // string matching
+      47             : //------------------------------------------------------------------------------
+      48             : 
+      49             : #define MATCH(s1,s2,n) (strncmp (s1, s2, n) == 0)
+      50             : #define MATCHNAME(s1,s2) MATCH (s1, s2, LAGRAPH_MAX_NAME_LEN)
+      51             : 
+      52             : //------------------------------------------------------------------------------
+      53             : // typedefs
+      54             : //------------------------------------------------------------------------------
+      55             : 
+      56             : // LG_void: used in place of (void *), but valid for pointer arithmetic
+      57             : typedef unsigned char LG_void ;
+      58             : 
+      59             : //------------------------------------------------------------------------------
+      60             : // LG_CLEAR_MSG: clear the error msg string
+      61             : //------------------------------------------------------------------------------
+      62             : 
+      63             : // When an LAGraph method starts, it first clears the caller's msg string.
+      64             : #define LG_CLEAR_MSG                    \
+      65             : {                                       \
+      66             :     if (msg != NULL) msg [0] = '\0' ;   \
+      67             : }
+      68             : 
+      69             : //------------------------------------------------------------------------------
+      70             : // LG_ERROR_MSG: set the error msg string
+      71             : //------------------------------------------------------------------------------
+      72             : 
+      73             : // When an LAGraph method encounters an error, it can report details in the
+      74             : // msg.  This is normally done via LG_ASSERT_MSG.  For example:
+      75             : 
+      76             : /*
+      77             :     if (src < 0 || src >= n)
+      78             :     {
+      79             :         LG_ERROR_MSG ("Source node %ld must be in range 0 to n-1, "
+      80             :             "where n = %ld is the number of nodes in the graph.", src, n) ;
+      81             :         return (GrB_INVALID_INDEX) ;
+      82             :     }
+      83             :     // or, with a simpler message:
+      84             :     LG_ASSERT_MSG (src >= 0 && src < n, GrB_INVALID_INDEX, "invalid src node") ;
+      85             : */
+      86             : 
+      87             : #define LG_ERROR_MSG(...)                                           \
+      88             : {                                                                   \
+      89             :     if (msg != NULL && msg [0] == '\0')                             \
+      90             :     {                                                               \
+      91             :         snprintf (msg, LAGRAPH_MSG_LEN, __VA_ARGS__) ;              \
+      92             :     }                                                               \
+      93             : }
+      94             : 
+      95             : //------------------------------------------------------------------------------
+      96             : // LG_FREE_WORK: free all workspace
+      97             : //------------------------------------------------------------------------------
+      98             : 
+      99             : #ifndef LG_FREE_WORK
+     100             : #define LG_FREE_WORK ;
+     101             : #endif
+     102             : 
+     103             : //------------------------------------------------------------------------------
+     104             : // LG_FREE_ALL: free all workspace and all output arguments, on error
+     105             : //------------------------------------------------------------------------------
+     106             : 
+     107             : #ifndef LG_FREE_ALL
+     108             : #define LG_FREE_ALL             \
+     109             : {                               \
+     110             :     LG_FREE_WORK ;              \
+     111             : }
+     112             : #endif
+     113             : 
+     114             : //------------------------------------------------------------------------------
+     115             : // GRB_CATCH: catch an error from GraphBLAS
+     116             : //------------------------------------------------------------------------------
+     117             : 
+     118             : // A simple GRB_CATCH macro to be used by GRB_TRY.  If an LAGraph function
+     119             : // wants something else, then #define a GRB_CATCH macro before the #include
+     120             : // "LG_internal.h" statement.
+     121             : 
+     122             : #ifndef GRB_CATCH
+     123             : #define GRB_CATCH(info)                                                 \
+     124             : {                                                                       \
+     125             :     LG_ERROR_MSG ("GraphBLAS failure (file %s, line %d): info: %d",     \
+     126             :         __FILE__, __LINE__, info) ;                                     \
+     127             :     LG_FREE_ALL ;                                                       \
+     128             :     return (info) ;                                                     \
+     129             : }
+     130             : #endif
+     131             : 
+     132             : //------------------------------------------------------------------------------
+     133             : // LAGRAPH_CATCH: catch an error from LAGraph
+     134             : //------------------------------------------------------------------------------
+     135             : 
+     136             : // A simple LAGRAPH_CATCH macro to be used by LAGRAPH_TRY.  If an LAGraph
+     137             : // function wants something else, then #define a LAGRAPH_CATCH macro before the
+     138             : // #include "LG_internal.h" statement.
+     139             : 
+     140             : #ifndef LAGRAPH_CATCH
+     141             : #define LAGRAPH_CATCH(status)                                           \
+     142             : {                                                                       \
+     143             :     LG_ERROR_MSG ("LAGraph failure (file %s, line %d): status: %d",     \
+     144             :         __FILE__, __LINE__, status) ;                                   \
+     145             :     LG_FREE_ALL ;                                                       \
+     146             :     return (status) ;                                                   \
+     147             : }
+     148             : #endif
+     149             : 
+     150             : //------------------------------------------------------------------------------
+     151             : // LG_ASSERT_MSGF: assert an expression is true, and return if it is false
+     152             : //------------------------------------------------------------------------------
+     153             : 
+     154             : // Identical to LG_ASSERT_MSG, except this allows a printf-style formatted
+     155             : // message.
+     156             : 
+     157             : #define LG_ASSERT_MSGF(expression,error_status,expression_format,...)   \
+     158             : {                                                                       \
+     159             :     if (!(expression))                                                  \
+     160             :     {                                                                   \
+     161             :         LG_ERROR_MSG ("LAGraph failure (file %s, line %d): "            \
+     162             :             expression_format, __FILE__, __LINE__, __VA_ARGS__) ;       \
+     163             :         LG_FREE_ALL ;                                                   \
+     164             :         return (error_status) ;                                         \
+     165             :     }                                                                   \
+     166             : }
+     167             : 
+     168             : //------------------------------------------------------------------------------
+     169             : // LG_ASSERT_MSG: assert an expression is true, and return if it is false
+     170             : //------------------------------------------------------------------------------
+     171             : 
+     172             : // Identical to LG_ASSERT, except this allows a different string to be
+     173             : // included in the message.
+     174             : 
+     175             : #define LG_ASSERT_MSG(expression,error_status,expression_message)       \
+     176             :     LG_ASSERT_MSGF (expression,error_status,"%s",expression_message)
+     177             : 
+     178             : //------------------------------------------------------------------------------
+     179             : // LG_ASSERT: assert an expression is true, and return if it is false
+     180             : //------------------------------------------------------------------------------
+     181             : 
+     182             : // LAGraph methods can use this assertion macro for simple errors.
+     183             : 
+     184             : #define LG_ASSERT(expression, error_status)                                 \
+     185             : {                                                                           \
+     186             :     if (!(expression))                                                      \
+     187             :     {                                                                       \
+     188             :         LG_ERROR_MSG ("LAGraph assertion \"%s\" failed (file %s, line %d):" \
+     189             :             " status: %d", LG_XSTR(expression), __FILE__, __LINE__,         \
+     190             :             error_status) ;                                                 \
+     191             :         LG_FREE_ALL ;                                                       \
+     192             :         return (error_status) ;                                             \
+     193             :     }                                                                       \
+     194             : }
+     195             : 
+     196             : //------------------------------------------------------------------------------
+     197             : // LG_TRY: check a condition and return on error
+     198             : //------------------------------------------------------------------------------
+     199             : 
+     200             : // The msg is not modified.  This should be used when an LAGraph method calls
+     201             : // another one.
+     202             : 
+     203             : #define LG_TRY(LAGraph_method)                  \
+     204             : {                                               \
+     205             :     int LAGraph_status = LAGraph_method ;       \
+     206             :     if (LAGraph_status < 0)                     \
+     207             :     {                                           \
+     208             :         LG_FREE_ALL ;                           \
+     209             :         return (LAGraph_status) ;               \
+     210             :     }                                           \
+     211             : }
+     212             : 
+     213             : //------------------------------------------------------------------------------
+     214             : // LG_CLEAR_MSG_AND_BASIC_ASSERT: clear msg and do basic tests of a graph
+     215             : //------------------------------------------------------------------------------
+     216             : 
+     217             : #define LG_CLEAR_MSG_AND_BASIC_ASSERT(G,msg)                                \
+     218             : {                                                                           \
+     219             :     LG_CLEAR_MSG ;                                                          \
+     220             :     LG_ASSERT (G != NULL, GrB_NULL_POINTER) ;                               \
+     221             :     LG_ASSERT_MSG (G->A != NULL, LAGRAPH_INVALID_GRAPH,                     \
+     222             :         "graph adjacency matrix is NULL") ;                                 \
+     223             :     LG_ASSERT_MSG (G->kind >= LAGraph_ADJACENCY_UNDIRECTED &&               \
+     224             :         G->kind <= LAGraph_ADJACENCY_DIRECTED,                              \
+     225             :         LAGRAPH_INVALID_GRAPH, "graph kind invalid") ;                      \
+     226             : }
+     227             : 
+     228             : //------------------------------------------------------------------------------
+     229             : // FPRINTF: fprintf and check result
+     230             : //------------------------------------------------------------------------------
+     231             : 
+     232             : #define FPRINTF(f,...)                                                      \
+     233             : {                                                                           \
+     234             :     LG_ASSERT_MSG (fprintf (f, __VA_ARGS__) >= 0,                           \
+     235             :         LAGRAPH_IO_ERROR, "Unable to write to file") ;                      \
+     236             : }
+     237             : 
+     238             : //------------------------------------------------------------------------------
+     239             : // code development settings
+     240             : //------------------------------------------------------------------------------
+     241             : 
+     242             : // turn off debugging; do not edit these three lines
+     243             : #ifndef NDEBUG
+     244             : #define NDEBUG
+     245             : #endif
+     246             : 
+     247             : // These flags are used for code development.  Uncomment them as needed.
+     248             : 
+     249             : // to turn on debugging, uncomment this line:
+     250             : // #undef NDEBUG
+     251             : 
+     252             : #undef ASSERT
+     253             : 
+     254             : #ifndef NDEBUG
+     255             : 
+     256             :     // debugging enabled
+     257             :     #ifdef MATLAB_MEX_FILE
+     258             :         // debugging when LAGraph is part of a mexFunction
+     259             :         #define ASSERT(x)                                               \
+     260             :         {                                                               \
+     261             :             if (!(x)) mexErrMsgTxt ("failure: " __FILE__ " line: ") ;   \
+     262             :         }
+     263             :     #else
+     264             :         #include <assert.h>
+     265             :         #define ASSERT(x) assert (x) ;
+     266             :     #endif
+     267             : 
+     268             : #else
+     269             : 
+     270             :     // debugging disabled
+     271             :     #define ASSERT(x)
+     272             : 
+     273             : #endif
+     274             : 
+     275             : //------------------------------------------------------------------------------
+     276             : // LG_Multiply_size_t:  c = a*b but check for overflow
+     277             : //------------------------------------------------------------------------------
+     278             : 
+     279       29649 : static bool LG_Multiply_size_t  // true if ok, false if overflow
+     280             : (
+     281             :     size_t *c,                  // c = a*b, or zero if overflow occurs
+     282             :     const size_t a,
+     283             :     const size_t b
+     284             : )
+     285             : {
+     286             : 
+     287             :     ASSERT (c != NULL) ;
+     288             : 
+     289       29649 :     (*c) = 0 ;
+     290       29649 :     if (a == 0 || b == 0)
+     291             :     {
+     292           1 :         return (true) ;
+     293             :     }
+     294             : 
+     295       29648 :     if (a > SIZE_MAX / 2 || b > SIZE_MAX / 2)
+     296             :     {
+     297             :         // a or b are out of range
+     298           4 :         return (false) ;
+     299             :     }
+     300             : 
+     301             :     // a + b is now safe to compute
+     302       29644 :     if ((a + b) > (SIZE_MAX / LAGRAPH_MIN (a,b)))
+     303             :     {
+     304             :         // a * b may overflow
+     305           1 :         return (false) ;
+     306             :     }
+     307             : 
+     308             :     // a * b will not overflow
+     309       29643 :     (*c) = a * b ;
+     310       29643 :     return (true) ;
+     311             : }
+     312             : 
+     313             : //------------------------------------------------------------------------------
+     314             : // Matrix Market format
+     315             : //------------------------------------------------------------------------------
+     316             : 
+     317             : // %%MatrixMarket matrix <fmt> <type> <storage> uses the following enums:
+     318             : 
+     319             : typedef enum
+     320             : {
+     321             :     MM_coordinate,
+     322             :     MM_array,
+     323             : }
+     324             : MM_fmt_enum ;
+     325             : 
+     326             : typedef enum
+     327             : {
+     328             :     MM_real,
+     329             :     MM_integer,
+     330             :     MM_complex,
+     331             :     MM_pattern
+     332             : }
+     333             : MM_type_enum ;
+     334             : 
+     335             : typedef enum
+     336             : {
+     337             :     MM_general,
+     338             :     MM_symmetric,
+     339             :     MM_skew_symmetric,
+     340             :     MM_hermitian
+     341             : }
+     342             : MM_storage_enum ;
+     343             : 
+     344             : // maximum length of each line in the Matrix Market file format
+     345             : 
+     346             : // The MatrixMarket format specificies a maximum line length of 1024.
+     347             : // This is currently sufficient for GraphBLAS but will need to be relaxed
+     348             : // if this function is extended to handle arbitrary user-defined types.
+     349             : #define MMLEN 1024
+     350             : #define MAXLINE MMLEN+6
+     351             : 
+     352             : //------------------------------------------------------------------------------
+     353             : // LG_PART and LG_PARTITION: definitions for partitioning an index range
+     354             : //------------------------------------------------------------------------------
+     355             : 
+     356             : LAGRAPH_PUBLIC extern
+     357             : int LG_nthreads_outer ; // # of threads to use at the higher level of a nested
+     358             :                         // parallel region in LAGraph.  Default: 1.
+     359             : 
+     360             : LAGRAPH_PUBLIC extern
+     361             : int LG_nthreads_inner ; // # of threads to use at the lower level of a nested
+     362             :                         // parallel region, or to use inside GraphBLAS.
+     363             :                         // Default: the value obtained by omp_get_max_threads
+     364             :                         // if OpenMP is in use, or 1 otherwise.
+     365             : 
+     366             : // LG_PART and LG_PARTITION:  divide the index range 0:n-1 uniformly
+     367             : // for nthreads.  LG_PART(tid,n,nthreads) is the first index for thread tid.
+     368             : #define LG_PART(tid,n,nthreads)  \
+     369             :     (((tid) * ((double) (n))) / ((double) (nthreads)))
+     370             : 
+     371             : // thread tid will operate on the range k1:(k2-1)
+     372             : #define LG_PARTITION(k1,k2,n,tid,nthreads)                                  \
+     373             :     k1 = ((tid) ==  0          ) ?  0  : LG_PART ((tid),  n, nthreads) ;    \
+     374             :     k2 = ((tid) == (nthreads)-1) ? (n) : LG_PART ((tid)+1,n, nthreads)
+     375             : 
+     376             : //------------------------------------------------------------------------------
+     377             : // LG_eslice: uniform partition of e items to each task
+     378             : //------------------------------------------------------------------------------
+     379             : 
+     380          12 : static inline void LG_eslice
+     381             : (
+     382             :     int64_t *Slice,         // array of size ntasks+1
+     383             :     int64_t e,              // number items to partition amongst the tasks
+     384             :     const int ntasks        // # of tasks
+     385             : )
+     386             : {
+     387          12 :     Slice [0] = 0 ;
+     388         204 :     for (int tid = 0 ; tid < ntasks ; tid++)
+     389             :     {
+     390         192 :         Slice [tid] = LG_PART (tid, e, ntasks) ;
+     391             :     }
+     392          12 :     Slice [ntasks] = e ;
+     393          12 : }
+     394             : 
+     395             : //------------------------------------------------------------------------------
+     396             : // definitions for sorting functions
+     397             : //------------------------------------------------------------------------------
+     398             : 
+     399             : // All of the LG_qsort_* functions are single-threaded, by design.  The
+     400             : // LG_msort* functions are parallel.  None of these sorting methods are
+     401             : // guaranteed to be stable.  These functions are contributed by Tim Davis, and
+     402             : // are derived from SuiteSparse:GraphBLAS.  Functions named LG_* are not
+     403             : // meant to be accessible by end users of LAGraph.
+     404             : 
+     405             : #define LG_BASECASE (64 * 1024)
+     406             : 
+     407             : //------------------------------------------------------------------------------
+     408             : // LG_msort1: sort array of size n
+     409             : //------------------------------------------------------------------------------
+     410             : 
+     411             : // LG_msort1 sorts an int64_t array of size n in ascending order.
+     412             : 
+     413             : int LG_msort1
+     414             : (
+     415             :     // input/output:
+     416             :     int64_t *A_0,       // size n array
+     417             :     // input:
+     418             :     const int64_t n,
+     419             :     char *msg
+     420             : ) ;
+     421             : 
+     422             : //------------------------------------------------------------------------------
+     423             : // LG_msort2: sort two arrays of size n
+     424             : //------------------------------------------------------------------------------
+     425             : 
+     426             : // LG_msort2 sorts two int64_t arrays A of size n in ascending order.
+     427             : // The arrays are kept in the same order, where the pair (A_0 [k], A_1 [k]) is
+     428             : // treated as a single pair.  The pairs are sorted by the first value A_0,
+     429             : // with ties broken by A_1.
+     430             : 
+     431             : int LG_msort2
+     432             : (
+     433             :     // input/output:
+     434             :     int64_t *A_0,       // size n array
+     435             :     int64_t *A_1,       // size n array
+     436             :     // input:
+     437             :     const int64_t n,
+     438             :     char *msg
+     439             : ) ;
+     440             : 
+     441             : //------------------------------------------------------------------------------
+     442             : // LG_msort3: sort three arrays of size n
+     443             : //------------------------------------------------------------------------------
+     444             : 
+     445             : // LG_msort3 sorts three int64_t arrays A of size n in ascending order.
+     446             : // The arrays are kept in the same order, where the triplet (A_0 [k], A_1 [k],
+     447             : // A_2 [k]) is treated as a single triplet.  The triplets are sorted by the
+     448             : // first value A_0, with ties broken by A_1, and then by A_2 if the values of
+     449             : // A_0 and A_1 are identical.
+     450             : 
+     451             : int LG_msort3
+     452             : (
+     453             :     // input/output:
+     454             :     int64_t *A_0,       // size n array
+     455             :     int64_t *A_1,       // size n array
+     456             :     int64_t *A_2,       // size n array
+     457             :     // input:
+     458             :     const int64_t n,
+     459             :     char *msg
+     460             : ) ;
+     461             : 
+     462             : void LG_qsort_1a    // sort array A of size 1-by-n
+     463             : (
+     464             :     int64_t *LG_RESTRICT A_0,       // size n array
+     465             :     const int64_t n
+     466             : ) ;
+     467             : 
+     468             : void LG_qsort_2     // sort array A of size 2-by-n, using 2 keys (A [0:1][])
+     469             : (
+     470             :     int64_t *LG_RESTRICT A_0,       // size n array
+     471             :     int64_t *LG_RESTRICT A_1,       // size n array
+     472             :     const int64_t n
+     473             : ) ;
+     474             : 
+     475             : void LG_qsort_3     // sort array A of size 3-by-n, using 3 keys (A [0:2][])
+     476             : (
+     477             :     int64_t *LG_RESTRICT A_0,       // size n array
+     478             :     int64_t *LG_RESTRICT A_1,       // size n array
+     479             :     int64_t *LG_RESTRICT A_2,       // size n array
+     480             :     const int64_t n
+     481             : ) ;
+     482             : 
+     483             : //------------------------------------------------------------------------------
+     484             : // LG_lt_1: sorting comparator function, one key
+     485             : //------------------------------------------------------------------------------
+     486             : 
+     487             : // A [a] and B [b] are keys of one integer.
+     488             : 
+     489             : // LG_lt_1 returns true if A [a] < B [b], for LG_qsort_1b
+     490             : 
+     491             : #define LG_lt_1(A_0, a, B_0, b) (A_0 [a] < B_0 [b])
+     492             : 
+     493             : //------------------------------------------------------------------------------
+     494             : // LG_lt_2: sorting comparator function, two keys
+     495             : //------------------------------------------------------------------------------
+     496             : 
+     497             : // A [a] and B [b] are keys of two integers.
+     498             : 
+     499             : // LG_lt_2 returns true if A [a] < B [b], for LG_qsort_2 and LG_msort_2b
+     500             : 
+     501             : #define LG_lt_2(A_0, A_1, a, B_0, B_1, b)                                   \
+     502             : (                                                                           \
+     503             :     (A_0 [a] < B_0 [b]) ?                                                   \
+     504             :     (                                                                       \
+     505             :         true                                                                \
+     506             :     )                                                                       \
+     507             :     :                                                                       \
+     508             :     (                                                                       \
+     509             :         (A_0 [a] == B_0 [b]) ?                                              \
+     510             :         (                                                                   \
+     511             :             /* primary key is the same; tie-break on the 2nd key */         \
+     512             :             (A_1 [a] < B_1 [b])                                             \
+     513             :         )                                                                   \
+     514             :         :                                                                   \
+     515             :         (                                                                   \
+     516             :             false                                                           \
+     517             :         )                                                                   \
+     518             :     )                                                                       \
+     519             : )
+     520             : 
+     521             : //------------------------------------------------------------------------------
+     522             : // LG_lt_3: sorting comparator function, three keys
+     523             : //------------------------------------------------------------------------------
+     524             : 
+     525             : // A [a] and B [b] are keys of three integers.
+     526             : 
+     527             : // LG_lt_3 returns true if A [a] < B [b], for LG_qsort_3 and LG_msort_3b
+     528             : 
+     529             : #define LG_lt_3(A_0, A_1, A_2, a, B_0, B_1, B_2, b)                         \
+     530             : (                                                                           \
+     531             :     (A_0 [a] < B_0 [b]) ?                                                   \
+     532             :     (                                                                       \
+     533             :         true                                                                \
+     534             :     )                                                                       \
+     535             :     :                                                                       \
+     536             :     (                                                                       \
+     537             :         (A_0 [a] == B_0 [b]) ?                                              \
+     538             :         (                                                                   \
+     539             :             /* primary key is the same; tie-break on the 2nd and 3rd key */ \
+     540             :             LG_lt_2 (A_1, A_2, a, B_1, B_2, b)                              \
+     541             :         )                                                                   \
+     542             :         :                                                                   \
+     543             :         (                                                                   \
+     544             :             false                                                           \
+     545             :         )                                                                   \
+     546             :     )                                                                       \
+     547             : )
+     548             : 
+     549             : //------------------------------------------------------------------------------
+     550             : // LG_eq_*: sorting comparator function, three keys
+     551             : //------------------------------------------------------------------------------
+     552             : 
+     553             : // A [a] and B [b] are keys of two or three integers.
+     554             : // LG_eq_* returns true if A [a] == B [b]
+     555             : 
+     556             : #define LG_eq_3(A_0, A_1, A_2, a, B_0, B_1, B_2, b)                         \
+     557             : (                                                                           \
+     558             :     (A_0 [a] == B_0 [b]) &&                                                 \
+     559             :     (A_1 [a] == B_1 [b]) &&                                                 \
+     560             :     (A_2 [a] == B_2 [b])                                                    \
+     561             : )
+     562             : 
+     563             : #define LG_eq_2(A_0, A_1, a, B_0, B_1, b)                                   \
+     564             : (                                                                           \
+     565             :     (A_0 [a] == B_0 [b]) &&                                                 \
+     566             :     (A_1 [a] == B_1 [b])                                                    \
+     567             : )
+     568             : 
+     569             : #define LG_eq_1(A_0, a, B_0, b)                                             \
+     570             : (                                                                           \
+     571             :     (A_0 [a] == B_0 [b])                                                    \
+     572             : )
+     573             : 
+     574             : //------------------------------------------------------------------------------
+     575             : // count entries on the diagonal of a matrix
+     576             : //------------------------------------------------------------------------------
+     577             : 
+     578             : int LG_nself_edges
+     579             : (
+     580             :     // output
+     581             :     int64_t *nself_edges,   // # of entries
+     582             :     // input
+     583             :     GrB_Matrix A,           // matrix to count
+     584             :     char *msg               // error message
+     585             : ) ;
+     586             : 
+     587             : //------------------------------------------------------------------------------
+     588             : // simple and portable random number generator (internal use only)
+     589             : //------------------------------------------------------------------------------
+     590             : 
+     591             : #define LG_RANDOM15_MAX 32767
+     592             : #define LG_RANDOM60_MAX ((1ULL << 60) -1)
+     593             : 
+     594             : // return a random number between 0 and LG_RANDOM15_MAX
+     595             : GrB_Index LG_Random15 (uint64_t *seed) ;
+     596             : 
+     597             : // return a random uint64_t, in range 0 to LG_RANDOM60_MAX
+     598             : GrB_Index LG_Random60 (uint64_t *seed) ;
+     599             : 
+     600             : //------------------------------------------------------------------------------
+     601             : // LG_KindName: return the name of a kind
+     602             : //------------------------------------------------------------------------------
+     603             : 
+     604             : // LG_KindName: return the name of a graph kind.  For example, if given
+     605             : // LAGraph_ADJACENCY_UNDIRECTED, the string "undirected" is returned.
+     606             : 
+     607             : int LG_KindName
+     608             : (
+     609             :     // output:
+     610             :     char *name,     // name of the kind (user provided array of size at least
+     611             :                     // LAGRAPH_MAX_NAME_LEN)
+     612             :     // input:
+     613             :     LAGraph_Kind kind,  // graph kind
+     614             :     char *msg
+     615             : ) ;
+     616             : 
+     617             : //------------------------------------------------------------------------------
+     618             : 
+     619             : // # of entries to print for LAGraph_Matrix_Print and LAGraph_Vector_Print
+     620             : #define LG_SHORT_LEN 30
+     621             : 
+     622             : #endif
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LG_msort1.c.func-sort-c.html b/src/utility/LG_msort1.c.func-sort-c.html new file mode 100644 index 0000000000..2ac4f243fa --- /dev/null +++ b/src/utility/LG_msort1.c.func-sort-c.html @@ -0,0 +1,88 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LG_msort1.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LG_msort1.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:107107100.0 %
Date:2024-08-29 20:08:04Functions:44100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_msort110
LG_msort_1b_binary_search196
LG_msort_1b_merge256
LG_msort_1b_create_merge_tasks452
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LG_msort1.c.func.html b/src/utility/LG_msort1.c.func.html new file mode 100644 index 0000000000..8c7f219047 --- /dev/null +++ b/src/utility/LG_msort1.c.func.html @@ -0,0 +1,88 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LG_msort1.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LG_msort1.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:107107100.0 %
Date:2024-08-29 20:08:04Functions:44100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_msort110
LG_msort_1b_binary_search196
LG_msort_1b_create_merge_tasks452
LG_msort_1b_merge256
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LG_msort1.c.gcov.html b/src/utility/LG_msort1.c.gcov.html new file mode 100644 index 0000000000..e8600787d0 --- /dev/null +++ b/src/utility/LG_msort1.c.gcov.html @@ -0,0 +1,547 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LG_msort1.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LG_msort1.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:107107100.0 %
Date:2024-08-29 20:08:04Functions:44100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LG_msort1: sort a list of integers
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // A parallel mergesort of an array of n integers.
+      19             : 
+      20             : #define LG_FREE_ALL LAGraph_Free ((void **) &W, NULL) ;
+      21             : 
+      22             : #include "LG_internal.h"
+      23             : 
+      24             : //------------------------------------------------------------------------------
+      25             : // prototype only needed for LG_msort1
+      26             : //------------------------------------------------------------------------------
+      27             : 
+      28             : void LG_msort_1b_create_merge_tasks
+      29             : (
+      30             :     // output:
+      31             :     int64_t *LG_RESTRICT L_task,        // L_task [t0...t0+ntasks-1] computed
+      32             :     int64_t *LG_RESTRICT L_len,         // L_len  [t0...t0+ntasks-1] computed
+      33             :     int64_t *LG_RESTRICT R_task,        // R_task [t0...t0+ntasks-1] computed
+      34             :     int64_t *LG_RESTRICT R_len,         // R_len  [t0...t0+ntasks-1] computed
+      35             :     int64_t *LG_RESTRICT S_task,        // S_task [t0...t0+ntasks-1] computed
+      36             :     // input:
+      37             :     const int t0,                       // first task tid to create
+      38             :     const int ntasks,                   // # of tasks to create
+      39             :     const int64_t pS_start,             // merge into S [pS_start...]
+      40             :     const int64_t *LG_RESTRICT L_0,     // Left = L [pL_start...pL_end-1]
+      41             :     const int64_t pL_start,
+      42             :     const int64_t pL_end,
+      43             :     const int64_t *LG_RESTRICT R_0,     // Right = R [pR_start...pR_end-1]
+      44             :     const int64_t pR_start,
+      45             :     const int64_t pR_end
+      46             : ) ;
+      47             : 
+      48             : //------------------------------------------------------------------------------
+      49             : // LG_msort_1b_binary_search: binary search for the pivot
+      50             : //------------------------------------------------------------------------------
+      51             : 
+      52             : // The Pivot value is Y [pivot], and a binary search for the Pivot is made in
+      53             : // the array X [p_pstart...p_end-1], which is sorted in non-decreasing order on
+      54             : // input.  The return value is pleft, where
+      55             : //
+      56             : //    X [p_start ... pleft-1] <= Pivot and
+      57             : //    X [pleft ... p_end-1] >= Pivot holds.
+      58             : //
+      59             : // pleft is returned in the range p_start to p_end.  If pleft is p_start, then
+      60             : // the Pivot is smaller than all entries in X [p_start...p_end-1], and the left
+      61             : // list X [p_start...pleft-1] is empty.  If pleft is p_end, then the Pivot is
+      62             : // larger than all entries in X [p_start...p_end-1], and the right list X
+      63             : // [pleft...p_end-1] is empty.
+      64             : 
+      65         196 : static int64_t LG_msort_1b_binary_search    // return pleft
+      66             : (
+      67             :     const int64_t *LG_RESTRICT Y_0,         // Pivot is Y [pivot]
+      68             :     const int64_t pivot,
+      69             :     const int64_t *LG_RESTRICT X_0,         // search in X [p_start..p_end_-1]
+      70             :     const int64_t p_start,
+      71             :     const int64_t p_end
+      72             : )
+      73             : {
+      74             : 
+      75             :     //--------------------------------------------------------------------------
+      76             :     // find where the Pivot appears in X
+      77             :     //--------------------------------------------------------------------------
+      78             : 
+      79             :     // binary search of X [p_start...p_end-1] for the Pivot
+      80         196 :     int64_t pleft = p_start ;
+      81         196 :     int64_t pright = p_end - 1 ;
+      82        2982 :     while (pleft < pright)
+      83             :     {
+      84        2786 :         int64_t pmiddle = (pleft + pright) >> 1 ;
+      85             :         // less = (X [pmiddle] < Pivot)
+      86        2786 :         bool less = LG_lt_1 (X_0, pmiddle,
+      87             :                              Y_0, pivot) ;
+      88        2786 :         pleft  = less ? (pmiddle+1) : pleft ;
+      89        2786 :         pright = less ? pright : pmiddle ;
+      90             :     }
+      91             : 
+      92             :     // binary search is narrowed down to a single item
+      93             :     // or it has found the list is empty:
+      94             :     ASSERT (pleft == pright || pleft == pright + 1) ;
+      95             : 
+      96             :     // If found is true then X [pleft == pright] == Pivot.  If duplicates
+      97             :     // appear then X [pleft] is any one of the entries equal to the Pivot
+      98             :     // in the list.  If found is false then
+      99             :     //    X [p_start ... pleft-1] < Pivot and
+     100             :     //    X [pleft+1 ... p_end-1] > Pivot holds.
+     101             :     //    The value X [pleft] may be either < or > Pivot.
+     102         196 :     bool found = (pleft == pright) && LG_eq_1 (X_0, pleft,
+     103             :                                                Y_0, pivot) ;
+     104             : 
+     105             :     // Modify pleft and pright:
+     106         196 :     if (!found && (pleft == pright))
+     107             :     {
+     108          26 :         if (LG_lt_1 (X_0, pleft,
+     109             :                      Y_0, pivot))
+     110             :         {
+     111           2 :             pleft++ ;
+     112             :         }
+     113             :         else
+     114             :         {
+     115             : //          pright++ ;  // (not needed)
+     116             :         }
+     117             :     }
+     118             : 
+     119             :     //--------------------------------------------------------------------------
+     120             :     // return result
+     121             :     //--------------------------------------------------------------------------
+     122             : 
+     123             :     // If found is false then
+     124             :     //    X [p_start ... pleft-1] < Pivot and
+     125             :     //    X [pleft ... p_end-1] > Pivot holds,
+     126             :     //    and pleft-1 == pright
+     127             : 
+     128             :     // If X has no duplicates, then whether or not Pivot is found,
+     129             :     //    X [p_start ... pleft-1] < Pivot and
+     130             :     //    X [pleft ... p_end-1] >= Pivot holds.
+     131             : 
+     132             :     // If X has duplicates, then whether or not Pivot is found,
+     133             :     //    X [p_start ... pleft-1] <= Pivot and
+     134             :     //    X [pleft ... p_end-1] >= Pivot holds.
+     135             : 
+     136         196 :     return (pleft) ;
+     137             : }
+     138             : 
+     139             : //------------------------------------------------------------------------------
+     140             : // LG_msort_1b_create_merge_tasks
+     141             : //------------------------------------------------------------------------------
+     142             : 
+     143             : // Recursively constructs ntasks tasks to merge two arrays, Left and Right,
+     144             : // into Sresult, where Left is L [pL_start...pL_end-1], Right is R
+     145             : // [pR_start...pR_end-1], and Sresult is S [pS_start...pS_start+total_work-1],
+     146             : // and where total_work is the total size of Left and Right.
+     147             : //
+     148             : // Task tid will merge L [L_task [tid] ... L_task [tid] + L_len [tid] - 1] and
+     149             : // R [R_task [tid] ... R_task [tid] + R_len [tid] -1] into the merged output
+     150             : // array S [S_task [tid] ... ].  The task tids created are t0 to
+     151             : // t0+ntasks-1.
+     152             : 
+     153         452 : void LG_msort_1b_create_merge_tasks
+     154             : (
+     155             :     // output:
+     156             :     int64_t *LG_RESTRICT L_task,        // L_task [t0...t0+ntasks-1] computed
+     157             :     int64_t *LG_RESTRICT L_len,         // L_len  [t0...t0+ntasks-1] computed
+     158             :     int64_t *LG_RESTRICT R_task,        // R_task [t0...t0+ntasks-1] computed
+     159             :     int64_t *LG_RESTRICT R_len,         // R_len  [t0...t0+ntasks-1] computed
+     160             :     int64_t *LG_RESTRICT S_task,        // S_task [t0...t0+ntasks-1] computed
+     161             :     // input:
+     162             :     const int t0,                       // first task tid to create
+     163             :     const int ntasks,                   // # of tasks to create
+     164             :     const int64_t pS_start,             // merge into S [pS_start...]
+     165             :     const int64_t *LG_RESTRICT L_0,     // Left = L [pL_start...pL_end-1]
+     166             :     const int64_t pL_start,
+     167             :     const int64_t pL_end,
+     168             :     const int64_t *LG_RESTRICT R_0,     // Right = R [pR_start...pR_end-1]
+     169             :     const int64_t pR_start,
+     170             :     const int64_t pR_end
+     171             : )
+     172             : {
+     173             : 
+     174             :     //--------------------------------------------------------------------------
+     175             :     // get problem size
+     176             :     //--------------------------------------------------------------------------
+     177             : 
+     178         452 :     int64_t nleft  = pL_end - pL_start ;        // size of Left array
+     179         452 :     int64_t nright = pR_end - pR_start ;        // size of Right array
+     180         452 :     int64_t total_work = nleft + nright ;       // total work to do
+     181             :     ASSERT (ntasks >= 1) ;
+     182             :     ASSERT (total_work > 0) ;
+     183             : 
+     184             :     //--------------------------------------------------------------------------
+     185             :     // create the tasks
+     186             :     //--------------------------------------------------------------------------
+     187             : 
+     188         452 :     if (ntasks == 1)
+     189             :     {
+     190             : 
+     191             :         //----------------------------------------------------------------------
+     192             :         // a single task will merge all of Left and Right into Sresult
+     193             :         //----------------------------------------------------------------------
+     194             : 
+     195         256 :         L_task [t0] = pL_start ; L_len [t0] = nleft ;
+     196         256 :         R_task [t0] = pR_start ; R_len [t0] = nright ;
+     197         256 :         S_task [t0] = pS_start ;
+     198             : 
+     199             :     }
+     200             :     else
+     201             :     {
+     202             : 
+     203             :         //----------------------------------------------------------------------
+     204             :         // partition the Left and Right arrays for multiple merge tasks
+     205             :         //----------------------------------------------------------------------
+     206             : 
+     207             :         int64_t pleft, pright ;
+     208         196 :         if (nleft >= nright)
+     209             :         {
+     210             :             // split Left in half, and search for its pivot in Right
+     211         130 :             pleft = (pL_end + pL_start) >> 1 ;
+     212         130 :             pright = LG_msort_1b_binary_search (
+     213             :                         L_0, pleft,
+     214             :                         R_0, pR_start, pR_end) ;
+     215             :         }
+     216             :         else
+     217             :         {
+     218             :             // split Right in half, and search for its pivot in Left
+     219          66 :             pright = (pR_end + pR_start) >> 1 ;
+     220          66 :             pleft = LG_msort_1b_binary_search (
+     221             :                         R_0, pright,
+     222             :                         L_0, pL_start, pL_end) ;
+     223             :         }
+     224             : 
+     225             :         //----------------------------------------------------------------------
+     226             :         // partition the tasks according to the work of each partition
+     227             :         //----------------------------------------------------------------------
+     228             : 
+     229             :         // work0 is the total work in the first partition
+     230         196 :         int64_t work0 = (pleft - pL_start) + (pright - pR_start) ;
+     231         196 :         int ntasks0 = (int) round ((double) ntasks *
+     232         196 :             (((double) work0) / ((double) total_work))) ;
+     233             : 
+     234             :         // ensure at least one task is assigned to each partition
+     235         196 :         ntasks0 = LAGRAPH_MAX (ntasks0, 1) ;
+     236         196 :         ntasks0 = LAGRAPH_MIN (ntasks0, ntasks-1) ;
+     237         196 :         int ntasks1 = ntasks - ntasks0 ;
+     238             : 
+     239             :         //----------------------------------------------------------------------
+     240             :         // assign ntasks0 to the first half
+     241             :         //----------------------------------------------------------------------
+     242             : 
+     243             :         // ntasks0 tasks merge L [pL_start...pleft-1] and R [pR_start..pright-1]
+     244             :         // into the result S [pS_start...work0-1].
+     245             : 
+     246         196 :         LG_msort_1b_create_merge_tasks (
+     247             :             L_task, L_len, R_task, R_len, S_task, t0, ntasks0, pS_start,
+     248             :             L_0, pL_start, pleft,
+     249             :             R_0, pR_start, pright) ;
+     250             : 
+     251             :         //----------------------------------------------------------------------
+     252             :         // assign ntasks1 to the second half
+     253             :         //----------------------------------------------------------------------
+     254             : 
+     255             :         // ntasks1 tasks merge L [pleft...pL_end-1] and R [pright...pR_end-1]
+     256             :         // into the result S [pS_start+work0...pS_start+total_work].
+     257             : 
+     258         196 :         int t1 = t0 + ntasks0 ;     // first task id of the second set of tasks
+     259         196 :         int64_t pS_start1 = pS_start + work0 ;  // 2nd set starts here in S
+     260         196 :         LG_msort_1b_create_merge_tasks (
+     261             :             L_task, L_len, R_task, R_len, S_task, t1, ntasks1, pS_start1,
+     262             :             L_0, pleft,  pL_end,
+     263             :             R_0, pright, pR_end) ;
+     264             :     }
+     265         452 : }
+     266             : 
+     267             : //------------------------------------------------------------------------------
+     268             : // LG_msort_1b_merge: merge two sorted lists via a single thread
+     269             : //------------------------------------------------------------------------------
+     270             : 
+     271             : // merge Left [0..nleft-1] and Right [0..nright-1] into S [0..nleft+nright-1] */
+     272             : 
+     273         256 : static void LG_msort_1b_merge
+     274             : (
+     275             :     int64_t *LG_RESTRICT S_0,              // output of length nleft + nright
+     276             :     const int64_t *LG_RESTRICT Left_0,     // left input of length nleft
+     277             :     const int64_t nleft,
+     278             :     const int64_t *LG_RESTRICT Right_0,    // right input of length nright
+     279             :     const int64_t nright
+     280             : )
+     281             : {
+     282             :     int64_t p, pleft, pright ;
+     283             : 
+     284             :     // merge the two inputs, Left and Right, while both inputs exist
+     285     3005484 :     for (p = 0, pleft = 0, pright = 0 ; pleft < nleft && pright < nright ; p++)
+     286             :     {
+     287     3005228 :         if (LG_lt_1 (Left_0,  pleft,
+     288             :                      Right_0, pright))
+     289             :         {
+     290             :             // S [p] = Left [pleft++]
+     291     1196146 :             S_0 [p] = Left_0 [pleft] ;
+     292     1196146 :             pleft++ ;
+     293             :         }
+     294             :         else
+     295             :         {
+     296             :             // S [p] = Right [pright++]
+     297     1809082 :             S_0 [p] = Right_0 [pright] ;
+     298     1809082 :             pright++ ;
+     299             :         }
+     300             :     }
+     301             : 
+     302             :     // either input is exhausted; copy the remaining list into S
+     303         256 :     if (pleft < nleft)
+     304             :     {
+     305         188 :         int64_t nremaining = (nleft - pleft) ;
+     306         188 :         memcpy (S_0 + p, Left_0 + pleft, nremaining * sizeof (int64_t)) ;
+     307             :     }
+     308          68 :     else if (pright < nright)
+     309             :     {
+     310          68 :         int64_t nremaining = (nright - pright) ;
+     311          68 :         memcpy (S_0 + p, Right_0 + pright, nremaining * sizeof (int64_t)) ;
+     312             :     }
+     313         256 : }
+     314             : 
+     315             : //------------------------------------------------------------------------------
+     316             : // LG_msort1: parallel mergesort
+     317             : //------------------------------------------------------------------------------
+     318             : 
+     319          10 : int LG_msort1
+     320             : (
+     321             :     // input/output:
+     322             :     int64_t *A_0,       // size n array
+     323             :     // input:
+     324             :     const int64_t n,
+     325             :     char *msg
+     326             : )
+     327             : {
+     328             : 
+     329             :     //--------------------------------------------------------------------------
+     330             :     // check inputs
+     331             :     //--------------------------------------------------------------------------
+     332             : 
+     333          10 :     LG_CLEAR_MSG ;
+     334          10 :     int64_t *LG_RESTRICT W = NULL ;
+     335          10 :     LG_ASSERT (A_0 != NULL, GrB_NULL_POINTER) ;
+     336             : 
+     337             :     //--------------------------------------------------------------------------
+     338             :     // handle small problems with a single thread
+     339             :     //--------------------------------------------------------------------------
+     340             : 
+     341          10 :     int nthreads = LG_nthreads_outer * LG_nthreads_inner ; // # threads to use
+     342          10 :     if (nthreads <= 1 || n <= LG_BASECASE)
+     343             :     {
+     344             :         // sequential quicksort
+     345           4 :         LG_qsort_1a (A_0, n) ;
+     346           4 :         return (GrB_SUCCESS) ;
+     347             :     }
+     348             : 
+     349             :     //--------------------------------------------------------------------------
+     350             :     // determine # of tasks
+     351             :     //--------------------------------------------------------------------------
+     352             : 
+     353             :     // determine the number of levels to create, which must always be an
+     354             :     // even number.  The # of levels is chosen to ensure that the # of leaves
+     355             :     // of the task tree is between 4*nthreads and 16*nthreads.
+     356             : 
+     357             :     //  2 to 4 threads:     4 levels, 16 qsort leaves
+     358             :     //  5 to 16 threads:    6 levels, 64 qsort leaves
+     359             :     // 17 to 64 threads:    8 levels, 256 qsort leaves
+     360             :     // 65 to 256 threads:   10 levels, 1024 qsort leaves
+     361             :     // 256 to 1024 threads: 12 levels, 4096 qsort leaves
+     362             :     // ...
+     363             : 
+     364           6 :     int k = (int) (2 + 2 * ceil (log2 ((double) nthreads) / 2)) ;
+     365           6 :     int ntasks = 1 << k ;
+     366             : 
+     367             :     //--------------------------------------------------------------------------
+     368             :     // allocate workspace
+     369             :     //--------------------------------------------------------------------------
+     370             : 
+     371           6 :     LG_TRY (LAGraph_Malloc ((void **) &W, n + 6*ntasks + 1, sizeof (int64_t), msg)) ;
+     372             : 
+     373           4 :     int64_t *T = W ;
+     374           4 :     int64_t *LG_RESTRICT W_0    = T ; T += n ;
+     375           4 :     int64_t *LG_RESTRICT L_task = T ; T += ntasks ;
+     376           4 :     int64_t *LG_RESTRICT L_len  = T ; T += ntasks ;
+     377           4 :     int64_t *LG_RESTRICT R_task = T ; T += ntasks ;
+     378           4 :     int64_t *LG_RESTRICT R_len  = T ; T += ntasks ;
+     379           4 :     int64_t *LG_RESTRICT S_task = T ; T += ntasks ;
+     380           4 :     int64_t *LG_RESTRICT Slice  = T ; T += (ntasks+1) ;
+     381             : 
+     382             :     //--------------------------------------------------------------------------
+     383             :     // partition and sort the leaves
+     384             :     //--------------------------------------------------------------------------
+     385             : 
+     386           4 :     LG_eslice (Slice, n, ntasks) ;
+     387             :     int tid ;
+     388             :     #pragma omp parallel for num_threads(nthreads) schedule(dynamic,1)
+     389          68 :     for (tid = 0 ; tid < ntasks ; tid++)
+     390             :     {
+     391          64 :         int64_t leaf = Slice [tid] ;
+     392          64 :         int64_t leafsize = Slice [tid+1] - leaf ;
+     393          64 :         LG_qsort_1a (A_0 + leaf, leafsize) ;
+     394             :     }
+     395             : 
+     396             :     //--------------------------------------------------------------------------
+     397             :     // merge each level
+     398             :     //--------------------------------------------------------------------------
+     399             : 
+     400           4 :     int nt = 1 ;
+     401          12 :     for ( ; k >= 2 ; k -= 2)
+     402             :     {
+     403             : 
+     404             :         //----------------------------------------------------------------------
+     405             :         // merge level k into level k-1, from A into W
+     406             :         //----------------------------------------------------------------------
+     407             : 
+     408             :         // FUTURE: skip k and k-1 for each group of 4 sublists of A if they are
+     409             :         // already sorted with respect to each other.
+     410             : 
+     411             :         // this could be done in parallel if ntasks was large
+     412          48 :         for (tid = 0 ; tid < ntasks ; tid += 2*nt)
+     413             :         {
+     414             :             // create 2*nt tasks to merge two A sublists into one W sublist
+     415          40 :             LG_msort_1b_create_merge_tasks (
+     416          40 :                 L_task, L_len, R_task, R_len, S_task, tid, 2*nt, Slice [tid],
+     417          40 :                 A_0, Slice [tid],    Slice [tid+nt],
+     418          40 :                 A_0, Slice [tid+nt], Slice [tid+2*nt]) ;
+     419             :         }
+     420             : 
+     421             :         #pragma omp parallel for num_threads(nthreads) schedule(dynamic,1)
+     422         136 :         for (tid = 0 ; tid < ntasks ; tid++)
+     423             :         {
+     424             :             // merge A [pL...pL+nL-1] and A [pR...pR+nR-1] into W [pS..]
+     425         128 :             int64_t pL = L_task [tid], nL = L_len [tid] ;
+     426         128 :             int64_t pR = R_task [tid], nR = R_len [tid] ;
+     427         128 :             int64_t pS = S_task [tid] ;
+     428             : 
+     429         128 :             LG_msort_1b_merge (
+     430         128 :                 W_0 + pS,
+     431         128 :                 A_0 + pL, nL,
+     432         128 :                 A_0 + pR, nR) ;
+     433             :         }
+     434           8 :         nt = 2*nt ;
+     435             : 
+     436             :         //----------------------------------------------------------------------
+     437             :         // merge level k-1 into level k-2, from W into A
+     438             :         //----------------------------------------------------------------------
+     439             : 
+     440             :         // this could be done in parallel if ntasks was large
+     441          28 :         for (tid = 0 ; tid < ntasks ; tid += 2*nt)
+     442             :         {
+     443             :             // create 2*nt tasks to merge two W sublists into one A sublist
+     444          20 :             LG_msort_1b_create_merge_tasks (
+     445          20 :                 L_task, L_len, R_task, R_len, S_task, tid, 2*nt, Slice [tid],
+     446          20 :                 W_0, Slice [tid],    Slice [tid+nt],
+     447          20 :                 W_0, Slice [tid+nt], Slice [tid+2*nt]) ;
+     448             :         }
+     449             : 
+     450             :         #pragma omp parallel for num_threads(nthreads) schedule(dynamic,1)
+     451         136 :         for (tid = 0 ; tid < ntasks ; tid++)
+     452             :         {
+     453             :             // merge A [pL...pL+nL-1] and A [pR...pR+nR-1] into W [pS..]
+     454         128 :             int64_t pL = L_task [tid], nL = L_len [tid] ;
+     455         128 :             int64_t pR = R_task [tid], nR = R_len [tid] ;
+     456         128 :             int64_t pS = S_task [tid] ;
+     457         128 :             LG_msort_1b_merge (
+     458         128 :                 A_0 + pS,
+     459         128 :                 W_0 + pL, nL,
+     460         128 :                 W_0 + pR, nR) ;
+     461             :         }
+     462           8 :         nt = 2*nt ;
+     463             :     }
+     464             : 
+     465             :     //--------------------------------------------------------------------------
+     466             :     // free workspace and return result
+     467             :     //--------------------------------------------------------------------------
+     468             : 
+     469           4 :     LG_FREE_ALL ;
+     470           4 :     return (GrB_SUCCESS) ;
+     471             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LG_msort2.c.func-sort-c.html b/src/utility/LG_msort2.c.func-sort-c.html new file mode 100644 index 0000000000..9c8c0559b4 --- /dev/null +++ b/src/utility/LG_msort2.c.func-sort-c.html @@ -0,0 +1,88 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LG_msort2.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LG_msort2.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:113113100.0 %
Date:2024-08-29 20:08:04Functions:44100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_msort_2b_binary_search196
LG_msort_2b_merge256
LG_msort_2b_create_merge_tasks452
LG_msort21663
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LG_msort2.c.func.html b/src/utility/LG_msort2.c.func.html new file mode 100644 index 0000000000..720beb0525 --- /dev/null +++ b/src/utility/LG_msort2.c.func.html @@ -0,0 +1,88 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LG_msort2.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LG_msort2.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:113113100.0 %
Date:2024-08-29 20:08:04Functions:44100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_msort21663
LG_msort_2b_binary_search196
LG_msort_2b_create_merge_tasks452
LG_msort_2b_merge256
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LG_msort2.c.gcov.html b/src/utility/LG_msort2.c.gcov.html new file mode 100644 index 0000000000..e397fa1d28 --- /dev/null +++ b/src/utility/LG_msort2.c.gcov.html @@ -0,0 +1,565 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LG_msort2.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LG_msort2.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:113113100.0 %
Date:2024-08-29 20:08:04Functions:44100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LG_msort2: sort a 2-by-n list of integers, using A[0:1][ ] as the key
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // A parallel mergesort of an array of 2-by-n integers.  Each key
+      19             : // consists of two integers.
+      20             : 
+      21             : #define LG_FREE_ALL LAGraph_Free ((void **) &W, NULL) ;
+      22             : 
+      23             : #include "LG_internal.h"
+      24             : 
+      25             : //------------------------------------------------------------------------------
+      26             : // prototype only needed for LG_msort2
+      27             : //------------------------------------------------------------------------------
+      28             : 
+      29             : void LG_msort_2b_create_merge_tasks
+      30             : (
+      31             :     // output:
+      32             :     int64_t *LG_RESTRICT L_task,        // L_task [t0...t0+ntasks-1] computed
+      33             :     int64_t *LG_RESTRICT L_len,         // L_len  [t0...t0+ntasks-1] computed
+      34             :     int64_t *LG_RESTRICT R_task,        // R_task [t0...t0+ntasks-1] computed
+      35             :     int64_t *LG_RESTRICT R_len,         // R_len  [t0...t0+ntasks-1] computed
+      36             :     int64_t *LG_RESTRICT S_task,        // S_task [t0...t0+ntasks-1] computed
+      37             :     // input:
+      38             :     const int t0,                       // first task tid to create
+      39             :     const int ntasks,                   // # of tasks to create
+      40             :     const int64_t pS_start,             // merge into S [pS_start...]
+      41             :     const int64_t *LG_RESTRICT L_0,     // Left = L [pL_start...pL_end-1]
+      42             :     const int64_t *LG_RESTRICT L_1,
+      43             :     const int64_t pL_start,
+      44             :     const int64_t pL_end,
+      45             :     const int64_t *LG_RESTRICT R_0,     // Right = R [pR_start...pR_end-1]
+      46             :     const int64_t *LG_RESTRICT R_1,
+      47             :     const int64_t pR_start,
+      48             :     const int64_t pR_end
+      49             : ) ;
+      50             : 
+      51             : //------------------------------------------------------------------------------
+      52             : // LG_msort_2b_binary_search: binary search for the pivot
+      53             : //------------------------------------------------------------------------------
+      54             : 
+      55             : // The Pivot value is Y [pivot], and a binary search for the Pivot is made in
+      56             : // the array X [p_pstart...p_end-1], which is sorted in non-decreasing order on
+      57             : // input.  The return value is pleft, where
+      58             : //
+      59             : //    X [p_start ... pleft-1] <= Pivot and
+      60             : //    X [pleft ... p_end-1] >= Pivot holds.
+      61             : //
+      62             : // pleft is returned in the range p_start to p_end.  If pleft is p_start, then
+      63             : // the Pivot is smaller than all entries in X [p_start...p_end-1], and the left
+      64             : // list X [p_start...pleft-1] is empty.  If pleft is p_end, then the Pivot is
+      65             : // larger than all entries in X [p_start...p_end-1], and the right list X
+      66             : // [pleft...p_end-1] is empty.
+      67             : 
+      68         196 : static int64_t LG_msort_2b_binary_search    // return pleft
+      69             : (
+      70             :     const int64_t *LG_RESTRICT Y_0,         // Pivot is Y [pivot]
+      71             :     const int64_t *LG_RESTRICT Y_1,
+      72             :     const int64_t pivot,
+      73             :     const int64_t *LG_RESTRICT X_0,         // search in X [p_start..p_end_-1]
+      74             :     const int64_t *LG_RESTRICT X_1,
+      75             :     const int64_t p_start,
+      76             :     const int64_t p_end
+      77             : )
+      78             : {
+      79             : 
+      80             :     //--------------------------------------------------------------------------
+      81             :     // find where the Pivot appears in X
+      82             :     //--------------------------------------------------------------------------
+      83             : 
+      84             :     // binary search of X [p_start...p_end-1] for the Pivot
+      85         196 :     int64_t pleft = p_start ;
+      86         196 :     int64_t pright = p_end - 1 ;
+      87        2980 :     while (pleft < pright)
+      88             :     {
+      89        2784 :         int64_t pmiddle = (pleft + pright) >> 1 ;
+      90             :         // less = (X [pmiddle] < Pivot)
+      91        2784 :         bool less = LG_lt_2 (X_0, X_1, pmiddle,
+      92             :                              Y_0, Y_1, pivot) ;
+      93        2784 :         pleft  = less ? (pmiddle+1) : pleft ;
+      94        2784 :         pright = less ? pright : pmiddle ;
+      95             :     }
+      96             : 
+      97             :     // binary search is narrowed down to a single item
+      98             :     // or it has found the list is empty:
+      99             :     ASSERT (pleft == pright || pleft == pright + 1) ;
+     100             : 
+     101             :     // If found is true then X [pleft == pright] == Pivot.  If duplicates
+     102             :     // appear then X [pleft] is any one of the entries equal to the Pivot
+     103             :     // in the list.  If found is false then
+     104             :     //    X [p_start ... pleft-1] < Pivot and
+     105             :     //    X [pleft+1 ... p_end-1] > Pivot holds.
+     106             :     //    The value X [pleft] may be either < or > Pivot.
+     107         196 :     bool found = (pleft == pright) && LG_eq_2 (X_0, X_1, pleft,
+     108             :                                                Y_0, Y_1, pivot) ;
+     109             : 
+     110             :     // Modify pleft and pright:
+     111         196 :     if (!found && (pleft == pright))
+     112             :     {
+     113         100 :         if (LG_lt_2 (X_0, X_1, pleft,
+     114             :                      Y_0, Y_1, pivot))
+     115             :         {
+     116           2 :             pleft++ ;
+     117             :         }
+     118             :         else
+     119             :         {
+     120             : //          pright++ ;  // (not needed)
+     121             :         }
+     122             :     }
+     123             : 
+     124             :     //--------------------------------------------------------------------------
+     125             :     // return result
+     126             :     //--------------------------------------------------------------------------
+     127             : 
+     128             :     // If found is false then
+     129             :     //    X [p_start ... pleft-1] < Pivot and
+     130             :     //    X [pleft ... p_end-1] > Pivot holds,
+     131             :     //    and pleft-1 == pright
+     132             : 
+     133             :     // If X has no duplicates, then whether or not Pivot is found,
+     134             :     //    X [p_start ... pleft-1] < Pivot and
+     135             :     //    X [pleft ... p_end-1] >= Pivot holds.
+     136             : 
+     137             :     // If X has duplicates, then whether or not Pivot is found,
+     138             :     //    X [p_start ... pleft-1] <= Pivot and
+     139             :     //    X [pleft ... p_end-1] >= Pivot holds.
+     140             : 
+     141         196 :     return (pleft) ;
+     142             : }
+     143             : 
+     144             : //------------------------------------------------------------------------------
+     145             : // LG_msort_2b_create_merge_tasks
+     146             : //------------------------------------------------------------------------------
+     147             : 
+     148             : // Recursively constructs ntasks tasks to merge two arrays, Left and Right,
+     149             : // into Sresult, where Left is L [pL_start...pL_end-1], Right is R
+     150             : // [pR_start...pR_end-1], and Sresult is S [pS_start...pS_start+total_work-1],
+     151             : // and where total_work is the total size of Left and Right.
+     152             : //
+     153             : // Task tid will merge L [L_task [tid] ... L_task [tid] + L_len [tid] - 1] and
+     154             : // R [R_task [tid] ... R_task [tid] + R_len [tid] -1] into the merged output
+     155             : // array S [S_task [tid] ... ].  The task tids created are t0 to
+     156             : // t0+ntasks-1.
+     157             : 
+     158         452 : void LG_msort_2b_create_merge_tasks
+     159             : (
+     160             :     // output:
+     161             :     int64_t *LG_RESTRICT L_task,        // L_task [t0...t0+ntasks-1] computed
+     162             :     int64_t *LG_RESTRICT L_len,         // L_len  [t0...t0+ntasks-1] computed
+     163             :     int64_t *LG_RESTRICT R_task,        // R_task [t0...t0+ntasks-1] computed
+     164             :     int64_t *LG_RESTRICT R_len,         // R_len  [t0...t0+ntasks-1] computed
+     165             :     int64_t *LG_RESTRICT S_task,        // S_task [t0...t0+ntasks-1] computed
+     166             :     // input:
+     167             :     const int t0,                       // first task tid to create
+     168             :     const int ntasks,                   // # of tasks to create
+     169             :     const int64_t pS_start,             // merge into S [pS_start...]
+     170             :     const int64_t *LG_RESTRICT L_0,     // Left = L [pL_start...pL_end-1]
+     171             :     const int64_t *LG_RESTRICT L_1,
+     172             :     const int64_t pL_start,
+     173             :     const int64_t pL_end,
+     174             :     const int64_t *LG_RESTRICT R_0,     // Right = R [pR_start...pR_end-1]
+     175             :     const int64_t *LG_RESTRICT R_1,
+     176             :     const int64_t pR_start,
+     177             :     const int64_t pR_end
+     178             : )
+     179             : {
+     180             : 
+     181             :     //--------------------------------------------------------------------------
+     182             :     // get problem size
+     183             :     //--------------------------------------------------------------------------
+     184             : 
+     185         452 :     int64_t nleft  = pL_end - pL_start ;        // size of Left array
+     186         452 :     int64_t nright = pR_end - pR_start ;        // size of Right array
+     187         452 :     int64_t total_work = nleft + nright ;       // total work to do
+     188             :     ASSERT (ntasks >= 1) ;
+     189             :     ASSERT (total_work > 0) ;
+     190             : 
+     191             :     //--------------------------------------------------------------------------
+     192             :     // create the tasks
+     193             :     //--------------------------------------------------------------------------
+     194             : 
+     195         452 :     if (ntasks == 1)
+     196             :     {
+     197             : 
+     198             :         //----------------------------------------------------------------------
+     199             :         // a single task will merge all of Left and Right into Sresult
+     200             :         //----------------------------------------------------------------------
+     201             : 
+     202         256 :         L_task [t0] = pL_start ; L_len [t0] = nleft ;
+     203         256 :         R_task [t0] = pR_start ; R_len [t0] = nright ;
+     204         256 :         S_task [t0] = pS_start ;
+     205             : 
+     206             :     }
+     207             :     else
+     208             :     {
+     209             : 
+     210             :         //----------------------------------------------------------------------
+     211             :         // partition the Left and Right arrays for multiple merge tasks
+     212             :         //----------------------------------------------------------------------
+     213             : 
+     214             :         int64_t pleft, pright ;
+     215         196 :         if (nleft >= nright)
+     216             :         {
+     217             :             // split Left in half, and search for its pivot in Right
+     218         134 :             pleft = (pL_end + pL_start) >> 1 ;
+     219         134 :             pright = LG_msort_2b_binary_search (
+     220             :                         L_0, L_1, pleft,
+     221             :                         R_0, R_1, pR_start, pR_end) ;
+     222             :         }
+     223             :         else
+     224             :         {
+     225             :             // split Right in half, and search for its pivot in Left
+     226          62 :             pright = (pR_end + pR_start) >> 1 ;
+     227          62 :             pleft = LG_msort_2b_binary_search (
+     228             :                         R_0, R_1, pright,
+     229             :                         L_0, L_1, pL_start, pL_end) ;
+     230             :         }
+     231             : 
+     232             :         //----------------------------------------------------------------------
+     233             :         // partition the tasks according to the work of each partition
+     234             :         //----------------------------------------------------------------------
+     235             : 
+     236             :         // work0 is the total work in the first partition
+     237         196 :         int64_t work0 = (pleft - pL_start) + (pright - pR_start) ;
+     238         196 :         int ntasks0 = (int) round ((double) ntasks *
+     239         196 :             (((double) work0) / ((double) total_work))) ;
+     240             : 
+     241             :         // ensure at least one task is assigned to each partition
+     242         196 :         ntasks0 = LAGRAPH_MAX (ntasks0, 1) ;
+     243         196 :         ntasks0 = LAGRAPH_MIN (ntasks0, ntasks-1) ;
+     244         196 :         int ntasks1 = ntasks - ntasks0 ;
+     245             : 
+     246             :         //----------------------------------------------------------------------
+     247             :         // assign ntasks0 to the first half
+     248             :         //----------------------------------------------------------------------
+     249             : 
+     250             :         // ntasks0 tasks merge L [pL_start...pleft-1] and R [pR_start..pright-1]
+     251             :         // into the result S [pS_start...work0-1].
+     252             : 
+     253         196 :         LG_msort_2b_create_merge_tasks (
+     254             :             L_task, L_len, R_task, R_len, S_task, t0, ntasks0, pS_start,
+     255             :             L_0, L_1, pL_start, pleft,
+     256             :             R_0, R_1, pR_start, pright) ;
+     257             : 
+     258             :         //----------------------------------------------------------------------
+     259             :         // assign ntasks1 to the second half
+     260             :         //----------------------------------------------------------------------
+     261             : 
+     262             :         // ntasks1 tasks merge L [pleft...pL_end-1] and R [pright...pR_end-1]
+     263             :         // into the result S [pS_start+work0...pS_start+total_work].
+     264             : 
+     265         196 :         int t1 = t0 + ntasks0 ;     // first task id of the second set of tasks
+     266         196 :         int64_t pS_start1 = pS_start + work0 ;  // 2nd set starts here in S
+     267         196 :         LG_msort_2b_create_merge_tasks (
+     268             :             L_task, L_len, R_task, R_len, S_task, t1, ntasks1, pS_start1,
+     269             :             L_0, L_1, pleft,  pL_end,
+     270             :             R_0, R_1, pright, pR_end) ;
+     271             :     }
+     272         452 : }
+     273             : 
+     274             : //------------------------------------------------------------------------------
+     275             : // LG_msort_2b_merge: merge two sorted lists via a single thread
+     276             : //------------------------------------------------------------------------------
+     277             : 
+     278             : // merge Left [0..nleft-1] and Right [0..nright-1] into S [0..nleft+nright-1] */
+     279             : 
+     280         256 : static void LG_msort_2b_merge
+     281             : (
+     282             :     int64_t *LG_RESTRICT S_0,              // output of length nleft + nright
+     283             :     int64_t *LG_RESTRICT S_1,
+     284             :     const int64_t *LG_RESTRICT Left_0,     // left input of length nleft
+     285             :     const int64_t *LG_RESTRICT Left_1,
+     286             :     const int64_t nleft,
+     287             :     const int64_t *LG_RESTRICT Right_0,    // right input of length nright
+     288             :     const int64_t *LG_RESTRICT Right_1,
+     289             :     const int64_t nright
+     290             : )
+     291             : {
+     292             :     int64_t p, pleft, pright ;
+     293             : 
+     294             :     // merge the two inputs, Left and Right, while both inputs exist
+     295     3005622 :     for (p = 0, pleft = 0, pright = 0 ; pleft < nleft && pright < nright ; p++)
+     296             :     {
+     297     3005366 :         if (LG_lt_2 (Left_0,  Left_1,  pleft,
+     298             :                      Right_0, Right_1, pright))
+     299             :         {
+     300             :             // S [p] = Left [pleft++]
+     301     1196304 :             S_0 [p] = Left_0 [pleft] ;
+     302     1196304 :             S_1 [p] = Left_1 [pleft] ;
+     303     1196304 :             pleft++ ;
+     304             :         }
+     305             :         else
+     306             :         {
+     307             :             // S [p] = Right [pright++]
+     308     1809062 :             S_0 [p] = Right_0 [pright] ;
+     309     1809062 :             S_1 [p] = Right_1 [pright] ;
+     310     1809062 :             pright++ ;
+     311             :         }
+     312             :     }
+     313             : 
+     314             :     // either input is exhausted; copy the remaining list into S
+     315         256 :     if (pleft < nleft)
+     316             :     {
+     317         170 :         int64_t nremaining = (nleft - pleft) ;
+     318         170 :         memcpy (S_0 + p, Left_0 + pleft, nremaining * sizeof (int64_t)) ;
+     319         170 :         memcpy (S_1 + p, Left_1 + pleft, nremaining * sizeof (int64_t)) ;
+     320             :     }
+     321          86 :     else if (pright < nright)
+     322             :     {
+     323          86 :         int64_t nremaining = (nright - pright) ;
+     324          86 :         memcpy (S_0 + p, Right_0 + pright, nremaining * sizeof (int64_t)) ;
+     325          86 :         memcpy (S_1 + p, Right_1 + pright, nremaining * sizeof (int64_t)) ;
+     326             :     }
+     327         256 : }
+     328             : 
+     329             : //------------------------------------------------------------------------------
+     330             : // LG_msort2: parallel mergesort
+     331             : //------------------------------------------------------------------------------
+     332             : 
+     333        1663 : int LG_msort2
+     334             : (
+     335             :     // input/output:
+     336             :     int64_t *A_0,       // size n array
+     337             :     int64_t *A_1,       // size n array
+     338             :     // input:
+     339             :     const int64_t n,
+     340             :     char *msg
+     341             : )
+     342             : {
+     343             : 
+     344             :     //--------------------------------------------------------------------------
+     345             :     // check inputs
+     346             :     //--------------------------------------------------------------------------
+     347             : 
+     348        1663 :     LG_CLEAR_MSG ;
+     349        1663 :     int64_t *LG_RESTRICT W = NULL ;
+     350        1663 :     LG_ASSERT (A_0 != NULL, GrB_NULL_POINTER) ;
+     351        1663 :     LG_ASSERT (A_1 != NULL, GrB_NULL_POINTER) ;
+     352             : 
+     353             :     //--------------------------------------------------------------------------
+     354             :     // handle small problems with a single thread
+     355             :     //--------------------------------------------------------------------------
+     356             : 
+     357        1663 :     int nthreads = LG_nthreads_outer * LG_nthreads_inner ; // # threads to use
+     358        1663 :     if (nthreads <= 1 || n <= LG_BASECASE)
+     359             :     {
+     360             :         // sequential quicksort
+     361        1657 :         LG_qsort_2 (A_0, A_1, n) ;
+     362        1657 :         return (GrB_SUCCESS) ;
+     363             :     }
+     364             : 
+     365             :     //--------------------------------------------------------------------------
+     366             :     // determine # of tasks
+     367             :     //--------------------------------------------------------------------------
+     368             : 
+     369             :     // determine the number of levels to create, which must always be an
+     370             :     // even number.  The # of levels is chosen to ensure that the # of leaves
+     371             :     // of the task tree is between 4*nthreads and 16*nthreads.
+     372             : 
+     373             :     //  2 to 4 threads:     4 levels, 16 qsort leaves
+     374             :     //  5 to 16 threads:    6 levels, 64 qsort leaves
+     375             :     // 17 to 64 threads:    8 levels, 256 qsort leaves
+     376             :     // 65 to 256 threads:   10 levels, 1024 qsort leaves
+     377             :     // 256 to 1024 threads: 12 levels, 4096 qsort leaves
+     378             :     // ...
+     379             : 
+     380           6 :     int k = (int) (2 + 2 * ceil (log2 ((double) nthreads) / 2)) ;
+     381           6 :     int ntasks = 1 << k ;
+     382             : 
+     383             :     //--------------------------------------------------------------------------
+     384             :     // allocate workspace
+     385             :     //--------------------------------------------------------------------------
+     386             : 
+     387           6 :     LG_TRY (LAGraph_Malloc ((void **) &W, 2*n + 6*ntasks + 1, sizeof (int64_t),
+     388             :         msg)) ;
+     389             : 
+     390           4 :     int64_t *T = W ;
+     391           4 :     int64_t *LG_RESTRICT W_0    = T ; T += n ;
+     392           4 :     int64_t *LG_RESTRICT W_1    = T ; T += n ;
+     393           4 :     int64_t *LG_RESTRICT L_task = T ; T += ntasks ;
+     394           4 :     int64_t *LG_RESTRICT L_len  = T ; T += ntasks ;
+     395           4 :     int64_t *LG_RESTRICT R_task = T ; T += ntasks ;
+     396           4 :     int64_t *LG_RESTRICT R_len  = T ; T += ntasks ;
+     397           4 :     int64_t *LG_RESTRICT S_task = T ; T += ntasks ;
+     398           4 :     int64_t *LG_RESTRICT Slice  = T ; T += (ntasks+1) ;
+     399             : 
+     400             :     //--------------------------------------------------------------------------
+     401             :     // partition and sort the leaves
+     402             :     //--------------------------------------------------------------------------
+     403             : 
+     404           4 :     LG_eslice (Slice, n, ntasks) ;
+     405             :     int tid ;
+     406             :     #pragma omp parallel for num_threads(nthreads) schedule(dynamic,1)
+     407          68 :     for (tid = 0 ; tid < ntasks ; tid++)
+     408             :     {
+     409          64 :         int64_t leaf = Slice [tid] ;
+     410          64 :         int64_t leafsize = Slice [tid+1] - leaf ;
+     411          64 :         LG_qsort_2 (A_0 + leaf, A_1 + leaf, leafsize) ;
+     412             :     }
+     413             : 
+     414             :     //--------------------------------------------------------------------------
+     415             :     // merge each level
+     416             :     //--------------------------------------------------------------------------
+     417             : 
+     418           4 :     int nt = 1 ;
+     419          12 :     for ( ; k >= 2 ; k -= 2)
+     420             :     {
+     421             : 
+     422             :         //----------------------------------------------------------------------
+     423             :         // merge level k into level k-1, from A into W
+     424             :         //----------------------------------------------------------------------
+     425             : 
+     426             :         // FUTURE: skip k and k-1 for each group of 4 sublists of A if they are
+     427             :         // already sorted with respect to each other.
+     428             : 
+     429             :         // this could be done in parallel if ntasks was large
+     430          48 :         for (tid = 0 ; tid < ntasks ; tid += 2*nt)
+     431             :         {
+     432             :             // create 2*nt tasks to merge two A sublists into one W sublist
+     433          40 :             LG_msort_2b_create_merge_tasks (
+     434          40 :                 L_task, L_len, R_task, R_len, S_task, tid, 2*nt, Slice [tid],
+     435          40 :                 A_0, A_1, Slice [tid],    Slice [tid+nt],
+     436          40 :                 A_0, A_1, Slice [tid+nt], Slice [tid+2*nt]) ;
+     437             :         }
+     438             : 
+     439             :         #pragma omp parallel for num_threads(nthreads) schedule(dynamic,1)
+     440         136 :         for (tid = 0 ; tid < ntasks ; tid++)
+     441             :         {
+     442             :             // merge A [pL...pL+nL-1] and A [pR...pR+nR-1] into W [pS..]
+     443         128 :             int64_t pL = L_task [tid], nL = L_len [tid] ;
+     444         128 :             int64_t pR = R_task [tid], nR = R_len [tid] ;
+     445         128 :             int64_t pS = S_task [tid] ;
+     446             : 
+     447         128 :             LG_msort_2b_merge (
+     448         128 :                 W_0 + pS, W_1 + pS,
+     449         128 :                 A_0 + pL, A_1 + pL, nL,
+     450         128 :                 A_0 + pR, A_1 + pR, nR) ;
+     451             :         }
+     452           8 :         nt = 2*nt ;
+     453             : 
+     454             :         //----------------------------------------------------------------------
+     455             :         // merge level k-1 into level k-2, from W into A
+     456             :         //----------------------------------------------------------------------
+     457             : 
+     458             :         // this could be done in parallel if ntasks was large
+     459          28 :         for (tid = 0 ; tid < ntasks ; tid += 2*nt)
+     460             :         {
+     461             :             // create 2*nt tasks to merge two W sublists into one A sublist
+     462          20 :             LG_msort_2b_create_merge_tasks (
+     463          20 :                 L_task, L_len, R_task, R_len, S_task, tid, 2*nt, Slice [tid],
+     464          20 :                 W_0, W_1, Slice [tid],    Slice [tid+nt],
+     465          20 :                 W_0, W_1, Slice [tid+nt], Slice [tid+2*nt]) ;
+     466             :         }
+     467             : 
+     468             :         #pragma omp parallel for num_threads(nthreads) schedule(dynamic,1)
+     469         136 :         for (tid = 0 ; tid < ntasks ; tid++)
+     470             :         {
+     471             :             // merge A [pL...pL+nL-1] and A [pR...pR+nR-1] into W [pS..]
+     472         128 :             int64_t pL = L_task [tid], nL = L_len [tid] ;
+     473         128 :             int64_t pR = R_task [tid], nR = R_len [tid] ;
+     474         128 :             int64_t pS = S_task [tid] ;
+     475         128 :             LG_msort_2b_merge (
+     476         128 :                 A_0 + pS, A_1 + pS,
+     477         128 :                 W_0 + pL, W_1 + pL, nL,
+     478         128 :                 W_0 + pR, W_1 + pR, nR) ;
+     479             :         }
+     480           8 :         nt = 2*nt ;
+     481             :     }
+     482             : 
+     483             :     //--------------------------------------------------------------------------
+     484             :     // free workspace and return result
+     485             :     //--------------------------------------------------------------------------
+     486             : 
+     487           4 :     LG_FREE_ALL ;
+     488           4 :     return (GrB_SUCCESS) ;
+     489             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LG_msort3.c.func-sort-c.html b/src/utility/LG_msort3.c.func-sort-c.html new file mode 100644 index 0000000000..756b02b03f --- /dev/null +++ b/src/utility/LG_msort3.c.func-sort-c.html @@ -0,0 +1,88 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LG_msort3.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LG_msort3.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:119119100.0 %
Date:2024-08-29 20:08:04Functions:44100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_msort3111
LG_msort_3b_binary_search196
LG_msort_3b_merge256
LG_msort_3b_create_merge_tasks452
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LG_msort3.c.func.html b/src/utility/LG_msort3.c.func.html new file mode 100644 index 0000000000..7a936ed402 --- /dev/null +++ b/src/utility/LG_msort3.c.func.html @@ -0,0 +1,88 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LG_msort3.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LG_msort3.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:119119100.0 %
Date:2024-08-29 20:08:04Functions:44100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_msort3111
LG_msort_3b_binary_search196
LG_msort_3b_create_merge_tasks452
LG_msort_3b_merge256
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LG_msort3.c.gcov.html b/src/utility/LG_msort3.c.gcov.html new file mode 100644 index 0000000000..0836846d3c --- /dev/null +++ b/src/utility/LG_msort3.c.gcov.html @@ -0,0 +1,578 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LG_msort3.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LG_msort3.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:119119100.0 %
Date:2024-08-29 20:08:04Functions:44100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LG_msort3: sort a 3-by-n list of integers, using A[0:2][ ] as the key
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // A parallel mergesort of an array of 3-by-n integers.  Each key
+      19             : // consists of three integers.
+      20             : 
+      21             : #define LG_FREE_ALL LAGraph_Free ((void **) &W, NULL) ;
+      22             : 
+      23             : #include "LG_internal.h"
+      24             : 
+      25             : //------------------------------------------------------------------------------
+      26             : // prototype only needed for LG_msort3
+      27             : //------------------------------------------------------------------------------
+      28             : 
+      29             : void LG_msort_3b_create_merge_tasks
+      30             : (
+      31             :     // output:
+      32             :     int64_t *LG_RESTRICT L_task,        // L_task [t0...t0+ntasks-1] computed
+      33             :     int64_t *LG_RESTRICT L_len,         // L_len  [t0...t0+ntasks-1] computed
+      34             :     int64_t *LG_RESTRICT R_task,        // R_task [t0...t0+ntasks-1] computed
+      35             :     int64_t *LG_RESTRICT R_len,         // R_len  [t0...t0+ntasks-1] computed
+      36             :     int64_t *LG_RESTRICT S_task,        // S_task [t0...t0+ntasks-1] computed
+      37             :     // input:
+      38             :     const int t0,                       // first task tid to create
+      39             :     const int ntasks,                   // # of tasks to create
+      40             :     const int64_t pS_start,             // merge into S [pS_start...]
+      41             :     const int64_t *LG_RESTRICT L_0,     // Left = L [pL_start...pL_end-1]
+      42             :     const int64_t *LG_RESTRICT L_1,
+      43             :     const int64_t *LG_RESTRICT L_2,
+      44             :     const int64_t pL_start,
+      45             :     const int64_t pL_end,
+      46             :     const int64_t *LG_RESTRICT R_0,     // Right = R [pR_start...pR_end-1]
+      47             :     const int64_t *LG_RESTRICT R_1,
+      48             :     const int64_t *LG_RESTRICT R_2,
+      49             :     const int64_t pR_start,
+      50             :     const int64_t pR_end
+      51             : ) ;
+      52             : 
+      53             : //------------------------------------------------------------------------------
+      54             : // LG_msort_3b_binary_search: binary search for the pivot
+      55             : //------------------------------------------------------------------------------
+      56             : 
+      57             : // The Pivot value is Y [pivot], and a binary search for the Pivot is made in
+      58             : // the array X [p_pstart...p_end-1], which is sorted in non-decreasing order on
+      59             : // input.  The return value is pleft, where
+      60             : //
+      61             : //    X [p_start ... pleft-1] <= Pivot and
+      62             : //    X [pleft ... p_end-1] >= Pivot holds.
+      63             : //
+      64             : // pleft is returned in the range p_start to p_end.  If pleft is p_start, then
+      65             : // the Pivot is smaller than all entries in X [p_start...p_end-1], and the left
+      66             : // list X [p_start...pleft-1] is empty.  If pleft is p_end, then the Pivot is
+      67             : // larger than all entries in X [p_start...p_end-1], and the right list X
+      68             : // [pleft...p_end-1] is empty.
+      69             : 
+      70         196 : static int64_t LG_msort_3b_binary_search    // return pleft
+      71             : (
+      72             :     const int64_t *LG_RESTRICT Y_0,         // Pivot is Y [pivot]
+      73             :     const int64_t *LG_RESTRICT Y_1,
+      74             :     const int64_t *LG_RESTRICT Y_2,
+      75             :     const int64_t pivot,
+      76             :     const int64_t *LG_RESTRICT X_0,         // search in X [p_start..p_end_-1]
+      77             :     const int64_t *LG_RESTRICT X_1,
+      78             :     const int64_t *LG_RESTRICT X_2,
+      79             :     const int64_t p_start,
+      80             :     const int64_t p_end
+      81             : )
+      82             : {
+      83             : 
+      84             :     //--------------------------------------------------------------------------
+      85             :     // find where the Pivot appears in X
+      86             :     //--------------------------------------------------------------------------
+      87             : 
+      88             :     // binary search of X [p_start...p_end-1] for the Pivot
+      89         196 :     int64_t pleft = p_start ;
+      90         196 :     int64_t pright = p_end - 1 ;
+      91        3030 :     while (pleft < pright)
+      92             :     {
+      93        2834 :         int64_t pmiddle = (pleft + pright) >> 1 ;
+      94             :         // less = (X [pmiddle] < Pivot)
+      95        2834 :         bool less = LG_lt_3 (X_0, X_1, X_2, pmiddle,
+      96             :                              Y_0, Y_1, Y_2, pivot) ;
+      97        2834 :         pleft  = less ? (pmiddle+1) : pleft ;
+      98        2834 :         pright = less ? pright : pmiddle ;
+      99             :     }
+     100             : 
+     101             :     // binary search is narrowed down to a single item
+     102             :     // or it has found the list is empty:
+     103             :     ASSERT (pleft == pright || pleft == pright + 1) ;
+     104             : 
+     105             :     // If found is true then X [pleft == pright] == Pivot.  If duplicates
+     106             :     // appear then X [pleft] is any one of the entries equal to the Pivot
+     107             :     // in the list.  If found is false then
+     108             :     //    X [p_start ... pleft-1] < Pivot and
+     109             :     //    X [pleft+1 ... p_end-1] > Pivot holds.
+     110             :     //    The value X [pleft] may be either < or > Pivot.
+     111         196 :     bool found = (pleft == pright) && LG_eq_3 (X_0, X_1, X_2, pleft,
+     112             :                                                Y_0, Y_1, Y_2, pivot) ;
+     113             : 
+     114             :     // Modify pleft and pright:
+     115         196 :     if (!found && (pleft == pright))
+     116             :     {
+     117         100 :         if (LG_lt_3 (X_0, X_1, X_2, pleft,
+     118             :                      Y_0, Y_1, Y_2, pivot))
+     119             :         {
+     120           2 :             pleft++ ;
+     121             :         }
+     122             :         else
+     123             :         {
+     124             : //          pright++ ;  // (not needed)
+     125             :         }
+     126             :     }
+     127             : 
+     128             :     //--------------------------------------------------------------------------
+     129             :     // return result
+     130             :     //--------------------------------------------------------------------------
+     131             : 
+     132             :     // If found is false then
+     133             :     //    X [p_start ... pleft-1] < Pivot and
+     134             :     //    X [pleft ... p_end-1] > Pivot holds,
+     135             :     //    and pleft-1 == pright
+     136             : 
+     137             :     // If X has no duplicates, then whether or not Pivot is found,
+     138             :     //    X [p_start ... pleft-1] < Pivot and
+     139             :     //    X [pleft ... p_end-1] >= Pivot holds.
+     140             : 
+     141             :     // If X has duplicates, then whether or not Pivot is found,
+     142             :     //    X [p_start ... pleft-1] <= Pivot and
+     143             :     //    X [pleft ... p_end-1] >= Pivot holds.
+     144             : 
+     145         196 :     return (pleft) ;
+     146             : }
+     147             : 
+     148             : //------------------------------------------------------------------------------
+     149             : // LG_msort_3b_create_merge_tasks
+     150             : //------------------------------------------------------------------------------
+     151             : 
+     152             : // Recursively constructs ntasks tasks to merge two arrays, Left and Right,
+     153             : // into Sresult, where Left is L [pL_start...pL_end-1], Right is R
+     154             : // [pR_start...pR_end-1], and Sresult is S [pS_start...pS_start+total_work-1],
+     155             : // and where total_work is the total size of Left and Right.
+     156             : //
+     157             : // Task tid will merge L [L_task [tid] ... L_task [tid] + L_len [tid] - 1] and
+     158             : // R [R_task [tid] ... R_task [tid] + R_len [tid] -1] into the merged output
+     159             : // array S [S_task [tid] ... ].  The task tids created are t0 to
+     160             : // t0+ntasks-1.
+     161             : 
+     162         452 : void LG_msort_3b_create_merge_tasks
+     163             : (
+     164             :     // output:
+     165             :     int64_t *LG_RESTRICT L_task,        // L_task [t0...t0+ntasks-1] computed
+     166             :     int64_t *LG_RESTRICT L_len,         // L_len  [t0...t0+ntasks-1] computed
+     167             :     int64_t *LG_RESTRICT R_task,        // R_task [t0...t0+ntasks-1] computed
+     168             :     int64_t *LG_RESTRICT R_len,         // R_len  [t0...t0+ntasks-1] computed
+     169             :     int64_t *LG_RESTRICT S_task,        // S_task [t0...t0+ntasks-1] computed
+     170             :     // input:
+     171             :     const int t0,                       // first task tid to create
+     172             :     const int ntasks,                   // # of tasks to create
+     173             :     const int64_t pS_start,             // merge into S [pS_start...]
+     174             :     const int64_t *LG_RESTRICT L_0,     // Left = L [pL_start...pL_end-1]
+     175             :     const int64_t *LG_RESTRICT L_1,
+     176             :     const int64_t *LG_RESTRICT L_2,
+     177             :     const int64_t pL_start,
+     178             :     const int64_t pL_end,
+     179             :     const int64_t *LG_RESTRICT R_0,     // Right = R [pR_start...pR_end-1]
+     180             :     const int64_t *LG_RESTRICT R_1,
+     181             :     const int64_t *LG_RESTRICT R_2,
+     182             :     const int64_t pR_start,
+     183             :     const int64_t pR_end
+     184             : )
+     185             : {
+     186             : 
+     187             :     //--------------------------------------------------------------------------
+     188             :     // get problem size
+     189             :     //--------------------------------------------------------------------------
+     190             : 
+     191         452 :     int64_t nleft  = pL_end - pL_start ;        // size of Left array
+     192         452 :     int64_t nright = pR_end - pR_start ;        // size of Right array
+     193         452 :     int64_t total_work = nleft + nright ;       // total work to do
+     194             :     ASSERT (ntasks >= 1) ;
+     195             :     ASSERT (total_work > 0) ;
+     196             : 
+     197             :     //--------------------------------------------------------------------------
+     198             :     // create the tasks
+     199             :     //--------------------------------------------------------------------------
+     200             : 
+     201         452 :     if (ntasks == 1)
+     202             :     {
+     203             : 
+     204             :         //----------------------------------------------------------------------
+     205             :         // a single task will merge all of Left and Right into Sresult
+     206             :         //----------------------------------------------------------------------
+     207             : 
+     208         256 :         L_task [t0] = pL_start ; L_len [t0] = nleft ;
+     209         256 :         R_task [t0] = pR_start ; R_len [t0] = nright ;
+     210         256 :         S_task [t0] = pS_start ;
+     211             : 
+     212             :     }
+     213             :     else
+     214             :     {
+     215             : 
+     216             :         //----------------------------------------------------------------------
+     217             :         // partition the Left and Right arrays for multiple merge tasks
+     218             :         //----------------------------------------------------------------------
+     219             : 
+     220             :         int64_t pleft, pright ;
+     221         196 :         if (nleft >= nright)
+     222             :         {
+     223             :             // split Left in half, and search for its pivot in Right
+     224         144 :             pleft = (pL_end + pL_start) >> 1 ;
+     225         144 :             pright = LG_msort_3b_binary_search (
+     226             :                         L_0, L_1, L_2, pleft,
+     227             :                         R_0, R_1, R_2, pR_start, pR_end) ;
+     228             :         }
+     229             :         else
+     230             :         {
+     231             :             // split Right in half, and search for its pivot in Left
+     232          52 :             pright = (pR_end + pR_start) >> 1 ;
+     233          52 :             pleft = LG_msort_3b_binary_search (
+     234             :                         R_0, R_1, R_2, pright,
+     235             :                         L_0, L_1, L_2, pL_start, pL_end) ;
+     236             :         }
+     237             : 
+     238             :         //----------------------------------------------------------------------
+     239             :         // partition the tasks according to the work of each partition
+     240             :         //----------------------------------------------------------------------
+     241             : 
+     242             :         // work0 is the total work in the first partition
+     243         196 :         int64_t work0 = (pleft - pL_start) + (pright - pR_start) ;
+     244         196 :         int ntasks0 = (int) round ((double) ntasks *
+     245         196 :             (((double) work0) / ((double) total_work))) ;
+     246             : 
+     247             :         // ensure at least one task is assigned to each partition
+     248         196 :         ntasks0 = LAGRAPH_MAX (ntasks0, 1) ;
+     249         196 :         ntasks0 = LAGRAPH_MIN (ntasks0, ntasks-1) ;
+     250         196 :         int ntasks1 = ntasks - ntasks0 ;
+     251             : 
+     252             :         //----------------------------------------------------------------------
+     253             :         // assign ntasks0 to the first half
+     254             :         //----------------------------------------------------------------------
+     255             : 
+     256             :         // ntasks0 tasks merge L [pL_start...pleft-1] and R [pR_start..pright-1]
+     257             :         // into the result S [pS_start...work0-1].
+     258             : 
+     259         196 :         LG_msort_3b_create_merge_tasks (
+     260             :             L_task, L_len, R_task, R_len, S_task, t0, ntasks0, pS_start,
+     261             :             L_0, L_1, L_2, pL_start, pleft,
+     262             :             R_0, R_1, R_2, pR_start, pright) ;
+     263             : 
+     264             :         //----------------------------------------------------------------------
+     265             :         // assign ntasks1 to the second half
+     266             :         //----------------------------------------------------------------------
+     267             : 
+     268             :         // ntasks1 tasks merge L [pleft...pL_end-1] and R [pright...pR_end-1]
+     269             :         // into the result S [pS_start+work0...pS_start+total_work].
+     270             : 
+     271         196 :         int t1 = t0 + ntasks0 ;     // first task id of the second set of tasks
+     272         196 :         int64_t pS_start1 = pS_start + work0 ;  // 2nd set starts here in S
+     273         196 :         LG_msort_3b_create_merge_tasks (
+     274             :             L_task, L_len, R_task, R_len, S_task, t1, ntasks1, pS_start1,
+     275             :             L_0, L_1, L_2, pleft,  pL_end,
+     276             :             R_0, R_1, R_2, pright, pR_end) ;
+     277             :     }
+     278         452 : }
+     279             : 
+     280             : //------------------------------------------------------------------------------
+     281             : // LG_msort_3b_merge: merge two sorted lists via a single thread
+     282             : //------------------------------------------------------------------------------
+     283             : 
+     284             : // merge Left [0..nleft-1] and Right [0..nright-1] into S [0..nleft+nright-1] */
+     285             : 
+     286         256 : static void LG_msort_3b_merge
+     287             : (
+     288             :     int64_t *LG_RESTRICT S_0,              // output of length nleft + nright
+     289             :     int64_t *LG_RESTRICT S_1,
+     290             :     int64_t *LG_RESTRICT S_2,
+     291             :     const int64_t *LG_RESTRICT Left_0,     // left input of length nleft
+     292             :     const int64_t *LG_RESTRICT Left_1,
+     293             :     const int64_t *LG_RESTRICT Left_2,
+     294             :     const int64_t nleft,
+     295             :     const int64_t *LG_RESTRICT Right_0,    // right input of length nright
+     296             :     const int64_t *LG_RESTRICT Right_1,
+     297             :     const int64_t *LG_RESTRICT Right_2,
+     298             :     const int64_t nright
+     299             : )
+     300             : {
+     301             :     int64_t p, pleft, pright ;
+     302             : 
+     303             :     // merge the two inputs, Left and Right, while both inputs exist
+     304     3688060 :     for (p = 0, pleft = 0, pright = 0 ; pleft < nleft && pright < nright ; p++)
+     305             :     {
+     306     3687804 :         if (LG_lt_3 (Left_0,  Left_1,  Left_2,  pleft,
+     307             :                      Right_0, Right_1, Right_2, pright))
+     308             :         {
+     309             :             // S [p] = Left [pleft++]
+     310     1668324 :             S_0 [p] = Left_0 [pleft] ;
+     311     1668324 :             S_1 [p] = Left_1 [pleft] ;
+     312     1668324 :             S_2 [p] = Left_2 [pleft] ;
+     313     1668324 :             pleft++ ;
+     314             :         }
+     315             :         else
+     316             :         {
+     317             :             // S [p] = Right [pright++]
+     318     2019480 :             S_0 [p] = Right_0 [pright] ;
+     319     2019480 :             S_1 [p] = Right_1 [pright] ;
+     320     2019480 :             S_2 [p] = Right_2 [pright] ;
+     321     2019480 :             pright++ ;
+     322             :         }
+     323             :     }
+     324             : 
+     325             :     // either input is exhausted; copy the remaining list into S
+     326         256 :     if (pleft < nleft)
+     327             :     {
+     328         176 :         int64_t nremaining = (nleft - pleft) ;
+     329         176 :         memcpy (S_0 + p, Left_0 + pleft, nremaining * sizeof (int64_t)) ;
+     330         176 :         memcpy (S_1 + p, Left_1 + pleft, nremaining * sizeof (int64_t)) ;
+     331         176 :         memcpy (S_2 + p, Left_2 + pleft, nremaining * sizeof (int64_t)) ;
+     332             :     }
+     333          80 :     else if (pright < nright)
+     334             :     {
+     335          80 :         int64_t nremaining = (nright - pright) ;
+     336          80 :         memcpy (S_0 + p, Right_0 + pright, nremaining * sizeof (int64_t)) ;
+     337          80 :         memcpy (S_1 + p, Right_1 + pright, nremaining * sizeof (int64_t)) ;
+     338          80 :         memcpy (S_2 + p, Right_2 + pright, nremaining * sizeof (int64_t)) ;
+     339             :     }
+     340         256 : }
+     341             : 
+     342             : //------------------------------------------------------------------------------
+     343             : // LG_msort3: parallel mergesort
+     344             : //------------------------------------------------------------------------------
+     345             : 
+     346         111 : int LG_msort3
+     347             : (
+     348             :     // input/output:
+     349             :     int64_t *A_0,       // size n array
+     350             :     int64_t *A_1,       // size n array
+     351             :     int64_t *A_2,       // size n array
+     352             :     // input:
+     353             :     const int64_t n,
+     354             :     char *msg
+     355             : )
+     356             : {
+     357             : 
+     358             :     //--------------------------------------------------------------------------
+     359             :     // check inputs
+     360             :     //--------------------------------------------------------------------------
+     361             : 
+     362         111 :     LG_CLEAR_MSG ;
+     363         111 :     int64_t *LG_RESTRICT W = NULL ;
+     364         111 :     LG_ASSERT (A_0 != NULL, GrB_NULL_POINTER) ;
+     365         111 :     LG_ASSERT (A_1 != NULL, GrB_NULL_POINTER) ;
+     366         111 :     LG_ASSERT (A_2 != NULL, GrB_NULL_POINTER) ;
+     367             : 
+     368             :     //--------------------------------------------------------------------------
+     369             :     // handle small problems with a single thread
+     370             :     //--------------------------------------------------------------------------
+     371             : 
+     372         111 :     int nthreads = LG_nthreads_outer * LG_nthreads_inner ; // # threads to use
+     373         111 :     if (nthreads <= 1 || n <= LG_BASECASE)
+     374             :     {
+     375             :         // sequential quicksort
+     376         105 :         LG_qsort_3 (A_0, A_1, A_2, n) ;
+     377         105 :         return (GrB_SUCCESS) ;
+     378             :     }
+     379             : 
+     380             :     //--------------------------------------------------------------------------
+     381             :     // determine # of tasks
+     382             :     //--------------------------------------------------------------------------
+     383             : 
+     384             :     // determine the number of levels to create, which must always be an
+     385             :     // even number.  The # of levels is chosen to ensure that the # of leaves
+     386             :     // of the task tree is between 4*nthreads and 16*nthreads.
+     387             : 
+     388             :     //  2 to 4 threads:     4 levels, 16 qsort leaves
+     389             :     //  5 to 16 threads:    6 levels, 64 qsort leaves
+     390             :     // 17 to 64 threads:    8 levels, 256 qsort leaves
+     391             :     // 65 to 256 threads:   10 levels, 1024 qsort leaves
+     392             :     // 256 to 1024 threads: 12 levels, 4096 qsort leaves
+     393             :     // ...
+     394             : 
+     395           6 :     int k = (int) (2 + 2 * ceil (log2 ((double) nthreads) / 2)) ;
+     396           6 :     int ntasks = 1 << k ;
+     397             : 
+     398             :     //--------------------------------------------------------------------------
+     399             :     // allocate workspace
+     400             :     //--------------------------------------------------------------------------
+     401             : 
+     402           6 :     LG_TRY (LAGraph_Malloc ((void **) &W, 3*n + 6*ntasks + 1, sizeof (int64_t),
+     403             :         msg)) ;
+     404             : 
+     405           4 :     int64_t *T = W ;
+     406           4 :     int64_t *LG_RESTRICT W_0    = T ; T += n ;
+     407           4 :     int64_t *LG_RESTRICT W_1    = T ; T += n ;
+     408           4 :     int64_t *LG_RESTRICT W_2    = T ; T += n ;
+     409           4 :     int64_t *LG_RESTRICT L_task = T ; T += ntasks ;
+     410           4 :     int64_t *LG_RESTRICT L_len  = T ; T += ntasks ;
+     411           4 :     int64_t *LG_RESTRICT R_task = T ; T += ntasks ;
+     412           4 :     int64_t *LG_RESTRICT R_len  = T ; T += ntasks ;
+     413           4 :     int64_t *LG_RESTRICT S_task = T ; T += ntasks ;
+     414           4 :     int64_t *LG_RESTRICT Slice  = T ; T += (ntasks+1) ;
+     415             : 
+     416             :     //--------------------------------------------------------------------------
+     417             :     // partition and sort the leaves
+     418             :     //--------------------------------------------------------------------------
+     419             : 
+     420           4 :     LG_eslice (Slice, n, ntasks) ;
+     421             :     int tid ;
+     422             :     #pragma omp parallel for num_threads(nthreads) schedule(dynamic,1)
+     423          68 :     for (tid = 0 ; tid < ntasks ; tid++)
+     424             :     {
+     425          64 :         int64_t leaf = Slice [tid] ;
+     426          64 :         int64_t leafsize = Slice [tid+1] - leaf ;
+     427          64 :         LG_qsort_3 (A_0 + leaf, A_1 + leaf, A_2 + leaf, leafsize) ;
+     428             :     }
+     429             : 
+     430             :     //--------------------------------------------------------------------------
+     431             :     // merge each level
+     432             :     //--------------------------------------------------------------------------
+     433             : 
+     434           4 :     int nt = 1 ;
+     435          12 :     for ( ; k >= 2 ; k -= 2)
+     436             :     {
+     437             : 
+     438             :         //----------------------------------------------------------------------
+     439             :         // merge level k into level k-1, from A into W
+     440             :         //----------------------------------------------------------------------
+     441             : 
+     442             :         // this could be done in parallel if ntasks was large
+     443          48 :         for (tid = 0 ; tid < ntasks ; tid += 2*nt)
+     444             :         {
+     445             :             // create 2*nt tasks to merge two A sublists into one W sublist
+     446          40 :             LG_msort_3b_create_merge_tasks (
+     447          40 :                 L_task, L_len, R_task, R_len, S_task, tid, 2*nt, Slice [tid],
+     448          40 :                 A_0, A_1, A_2, Slice [tid],    Slice [tid+nt],
+     449          40 :                 A_0, A_1, A_2, Slice [tid+nt], Slice [tid+2*nt]) ;
+     450             :         }
+     451             : 
+     452             :         #pragma omp parallel for num_threads(nthreads) schedule(dynamic,1)
+     453         136 :         for (tid = 0 ; tid < ntasks ; tid++)
+     454             :         {
+     455             :             // merge A [pL...pL+nL-1] and A [pR...pR+nR-1] into W [pS..]
+     456         128 :             int64_t pL = L_task [tid], nL = L_len [tid] ;
+     457         128 :             int64_t pR = R_task [tid], nR = R_len [tid] ;
+     458         128 :             int64_t pS = S_task [tid] ;
+     459             : 
+     460         128 :             LG_msort_3b_merge (
+     461         128 :                 W_0 + pS, W_1 + pS, W_2 + pS,
+     462         128 :                 A_0 + pL, A_1 + pL, A_2 + pL, nL,
+     463         128 :                 A_0 + pR, A_1 + pR, A_2 + pR, nR) ;
+     464             :         }
+     465           8 :         nt = 2*nt ;
+     466             : 
+     467             :         //----------------------------------------------------------------------
+     468             :         // merge level k-1 into level k-2, from W into A
+     469             :         //----------------------------------------------------------------------
+     470             : 
+     471             :         // this could be done in parallel if ntasks was large
+     472          28 :         for (tid = 0 ; tid < ntasks ; tid += 2*nt)
+     473             :         {
+     474             :             // create 2*nt tasks to merge two W sublists into one A sublist
+     475          20 :             LG_msort_3b_create_merge_tasks (
+     476          20 :                 L_task, L_len, R_task, R_len, S_task, tid, 2*nt, Slice [tid],
+     477          20 :                 W_0, W_1, W_2, Slice [tid],    Slice [tid+nt],
+     478          20 :                 W_0, W_1, W_2, Slice [tid+nt], Slice [tid+2*nt]) ;
+     479             :         }
+     480             : 
+     481             :         #pragma omp parallel for num_threads(nthreads) schedule(dynamic,1)
+     482         136 :         for (tid = 0 ; tid < ntasks ; tid++)
+     483             :         {
+     484             :             // merge A [pL...pL+nL-1] and A [pR...pR+nR-1] into W [pS..]
+     485         128 :             int64_t pL = L_task [tid], nL = L_len [tid] ;
+     486         128 :             int64_t pR = R_task [tid], nR = R_len [tid] ;
+     487         128 :             int64_t pS = S_task [tid] ;
+     488         128 :             LG_msort_3b_merge (
+     489         128 :                 A_0 + pS, A_1 + pS, A_2 + pS,
+     490         128 :                 W_0 + pL, W_1 + pL, W_2 + pL, nL,
+     491         128 :                 W_0 + pR, W_1 + pR, W_2 + pR, nR) ;
+     492             :         }
+     493           8 :         nt = 2*nt ;
+     494             :     }
+     495             : 
+     496             :     //--------------------------------------------------------------------------
+     497             :     // free workspace and return result
+     498             :     //--------------------------------------------------------------------------
+     499             : 
+     500           4 :     LG_FREE_ALL ;
+     501           4 :     return (GrB_SUCCESS) ;
+     502             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LG_nself_edges.c.func-sort-c.html b/src/utility/LG_nself_edges.c.func-sort-c.html new file mode 100644 index 0000000000..c74177970d --- /dev/null +++ b/src/utility/LG_nself_edges.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LG_nself_edges.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LG_nself_edges.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1515100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_nself_edges941
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LG_nself_edges.c.func.html b/src/utility/LG_nself_edges.c.func.html new file mode 100644 index 0000000000..68d50127b6 --- /dev/null +++ b/src/utility/LG_nself_edges.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LG_nself_edges.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LG_nself_edges.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1515100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_nself_edges941
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LG_nself_edges.c.gcov.html b/src/utility/LG_nself_edges.c.gcov.html new file mode 100644 index 0000000000..bb3c13a1c3 --- /dev/null +++ b/src/utility/LG_nself_edges.c.gcov.html @@ -0,0 +1,167 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LG_nself_edges.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LG_nself_edges.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:1515100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LG_nself_edges: count the # of diagonal entries in a matrix
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #define LG_FREE_ALL         \
+      19             : {                           \
+      20             :     GrB_free (&M) ;         \
+      21             :     GrB_free (&D) ;         \
+      22             :     GrB_free (&d) ;         \
+      23             : }
+      24             : 
+      25             : #include "LG_internal.h"
+      26             : 
+      27         941 : int LG_nself_edges
+      28             : (
+      29             :     // output:
+      30             :     int64_t *nself_edges,         // # of entries
+      31             :     // input:
+      32             :     GrB_Matrix A,           // matrix to count
+      33             :     char *msg               // error message
+      34             : )
+      35             : {
+      36             : 
+      37             :     //--------------------------------------------------------------------------
+      38             :     // extract the diagonal and count its entries
+      39             :     //--------------------------------------------------------------------------
+      40             : 
+      41         941 :     GrB_Matrix D = NULL, M = NULL ;
+      42         941 :     GrB_Vector d = NULL ;
+      43         941 :     LG_ASSERT (nself_edges != NULL, GrB_NULL_POINTER) ;
+      44         941 :     (*nself_edges) = LAGRAPH_UNKNOWN ;
+      45             : 
+      46             :     GrB_Index nrows, ncols ;
+      47         941 :     GRB_TRY (GrB_Matrix_nrows (&nrows, A)) ;
+      48         941 :     GRB_TRY (GrB_Matrix_ncols (&ncols, A)) ;
+      49         941 :     GrB_Index n = LAGRAPH_MIN (nrows, ncols) ;
+      50             : 
+      51             :     // FUTURE: use a method that does not require atype
+      52             : 
+      53             :     GrB_Type atype ;
+      54             :     char atype_name [LAGRAPH_MAX_NAME_LEN] ;
+      55         941 :     LG_TRY (LAGraph_Matrix_TypeName (atype_name, A, msg)) ;
+      56         941 :     LG_TRY (LAGraph_TypeFromName (&atype, atype_name, msg)) ;
+      57             : 
+      58             :     #if LAGRAPH_SUITESPARSE
+      59             : 
+      60             :         //----------------------------------------------------------------------
+      61             :         // SuiteSparse:GraphBLAS v5.0.2: use GxB_Vector_diag
+      62             :         //----------------------------------------------------------------------
+      63             : 
+      64         941 :         GRB_TRY (GrB_Vector_new (&d, atype, n)) ;
+      65         809 :         GRB_TRY (GxB_Vector_diag (d, A, 0, NULL)) ;
+      66         316 :         GRB_TRY (GrB_Vector_nvals ((GrB_Index *) nself_edges, d)) ;
+      67             : 
+      68             :     #else
+      69             : 
+      70             :         //----------------------------------------------------------------------
+      71             :         // pure GrB version with no GxB extensions
+      72             :         //----------------------------------------------------------------------
+      73             : 
+      74             :         GRB_TRY (GrB_Matrix_new (&M, GrB_BOOL, nrows, ncols)) ;
+      75             :         GRB_TRY (GrB_Matrix_new (&D, atype, nrows, ncols)) ;
+      76             :         for (int64_t i = 0 ; i < n ; i++)
+      77             :         {
+      78             :             // M (i,i) = true
+      79             :             GRB_TRY (GrB_Matrix_setElement (M, (bool) true, i, i)) ;
+      80             :         }
+      81             : 
+      82             :         // D<M,struct> = A
+      83             :         GRB_TRY (GrB_assign (D, M, NULL, A, GrB_ALL, nrows, GrB_ALL, ncols,
+      84             :             GrB_DESC_S)) ;
+      85             :         GRB_TRY (GrB_Matrix_nvals ((GrB_Index *) nself_edges, D)) ;
+      86             : 
+      87             :     #endif
+      88             : 
+      89         316 :     LG_FREE_ALL ;
+      90         316 :     return (GrB_SUCCESS) ;
+      91             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LG_qsort_1a.c.func-sort-c.html b/src/utility/LG_qsort_1a.c.func-sort-c.html new file mode 100644 index 0000000000..936c0906a7 --- /dev/null +++ b/src/utility/LG_qsort_1a.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LG_qsort_1a.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LG_qsort_1a.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:44100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_qsort_1a254
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LG_qsort_1a.c.func.html b/src/utility/LG_qsort_1a.c.func.html new file mode 100644 index 0000000000..71aa9c5733 --- /dev/null +++ b/src/utility/LG_qsort_1a.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LG_qsort_1a.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LG_qsort_1a.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:44100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_qsort_1a254
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LG_qsort_1a.c.gcov.html b/src/utility/LG_qsort_1a.c.gcov.html new file mode 100644 index 0000000000..e510efa8ff --- /dev/null +++ b/src/utility/LG_qsort_1a.c.gcov.html @@ -0,0 +1,134 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LG_qsort_1a.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LG_qsort_1a.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:44100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LG_qsort_1a: sort an 1-by-n list of integers
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include "LG_internal.h"
+      19             : 
+      20             : // returns true if A [a] < B [b]
+      21             : #define LG_lt(A,a,B,b)                  \
+      22             :     LG_lt_1 (A ## _0, a, B ## _0, b)
+      23             : 
+      24             : // argument list for calling a function
+      25             : #define LG_arg(A)                       \
+      26             :     A ## _0
+      27             : 
+      28             : // argument list for calling a function, with offset
+      29             : #define LG_arg_offset(A,x)              \
+      30             :     A ## _0 + (x)
+      31             : 
+      32             : // argument list for defining a function
+      33             : #define LG_args(A)                      \
+      34             :     int64_t *LG_RESTRICT A ## _0
+      35             : 
+      36             : // each entry has a single key
+      37             : #define LG_K 1
+      38             : 
+      39             : // swap A [a] and A [b]
+      40             : #define LG_swap(A,a,b)                                                        \
+      41             : {                                                                             \
+      42             :     int64_t t0 = A ## _0 [a] ; A ## _0 [a] = A ## _0 [b] ; A ## _0 [b] = t0 ; \
+      43             : }
+      44             : 
+      45             : #define LG_partition LG_partition_1a
+      46             : #define LG_quicksort LG_quicksort_1a
+      47             : 
+      48             : #include "LG_qsort_template.h"
+      49             : 
+      50         254 : void LG_qsort_1a    // sort array A of size 1-by-n
+      51             : (
+      52             :     int64_t *LG_RESTRICT A_0,       // size n array
+      53             :     const int64_t n
+      54             : )
+      55             : {
+      56         254 :     uint64_t seed = n ;
+      57         254 :     LG_quicksort (LG_arg (A), n, &seed, NULL) ;
+      58         254 : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LG_qsort_2.c.func-sort-c.html b/src/utility/LG_qsort_2.c.func-sort-c.html new file mode 100644 index 0000000000..7e55837228 --- /dev/null +++ b/src/utility/LG_qsort_2.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LG_qsort_2.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LG_qsort_2.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:44100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_qsort_21721
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LG_qsort_2.c.func.html b/src/utility/LG_qsort_2.c.func.html new file mode 100644 index 0000000000..f15c582663 --- /dev/null +++ b/src/utility/LG_qsort_2.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LG_qsort_2.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LG_qsort_2.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:44100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_qsort_21721
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LG_qsort_2.c.gcov.html b/src/utility/LG_qsort_2.c.gcov.html new file mode 100644 index 0000000000..af8f3c1634 --- /dev/null +++ b/src/utility/LG_qsort_2.c.gcov.html @@ -0,0 +1,137 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LG_qsort_2.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LG_qsort_2.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:44100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LG_qsort_2: sort a 2-by-n list of integers, using A[0:1][ ] as the key
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include "LG_internal.h"
+      19             : 
+      20             : // returns true if A [a] < B [b]
+      21             : #define LG_lt(A,a,B,b)                  \
+      22             :     LG_lt_2 (A ## _0, A ## _1, a, B ## _0, B ## _1, b)
+      23             : 
+      24             : // argument list for calling a function
+      25             : #define LG_arg(A)                       \
+      26             :     A ## _0, A ## _1
+      27             : 
+      28             : // argument list for calling a function, with offset
+      29             : #define LG_arg_offset(A,x)              \
+      30             :     A ## _0 + (x), A ## _1 + (x)
+      31             : 
+      32             : // argument list for defining a function
+      33             : #define LG_args(A)                      \
+      34             :     int64_t *LG_RESTRICT A ## _0,       \
+      35             :     int64_t *LG_RESTRICT A ## _1
+      36             : 
+      37             : // each entry has a 2-integer key
+      38             : #define LG_K 2
+      39             : 
+      40             : // swap A [a] and A [b]
+      41             : #define LG_swap(A,a,b)                                                        \
+      42             : {                                                                             \
+      43             :     int64_t t0 = A ## _0 [a] ; A ## _0 [a] = A ## _0 [b] ; A ## _0 [b] = t0 ; \
+      44             :     int64_t t1 = A ## _1 [a] ; A ## _1 [a] = A ## _1 [b] ; A ## _1 [b] = t1 ; \
+      45             : }
+      46             : 
+      47             : #define LG_partition LG_partition_2
+      48             : #define LG_quicksort LG_quicksort_2
+      49             : 
+      50             : #include "LG_qsort_template.h"
+      51             : 
+      52        1721 : void LG_qsort_2     // sort array A of size 2-by-n, using 2 keys (A [0:1][])
+      53             : (
+      54             :     int64_t *LG_RESTRICT A_0,       // size n array
+      55             :     int64_t *LG_RESTRICT A_1,       // size n array
+      56             :     const int64_t n
+      57             : )
+      58             : {
+      59        1721 :     uint64_t seed = n ;
+      60        1721 :     LG_quicksort (LG_arg (A), n, &seed, NULL) ;
+      61        1721 : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LG_qsort_3.c.func-sort-c.html b/src/utility/LG_qsort_3.c.func-sort-c.html new file mode 100644 index 0000000000..cc2abed324 --- /dev/null +++ b/src/utility/LG_qsort_3.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LG_qsort_3.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LG_qsort_3.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:44100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_qsort_3169
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LG_qsort_3.c.func.html b/src/utility/LG_qsort_3.c.func.html new file mode 100644 index 0000000000..b3a217c7b9 --- /dev/null +++ b/src/utility/LG_qsort_3.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LG_qsort_3.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LG_qsort_3.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:44100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_qsort_3169
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LG_qsort_3.c.gcov.html b/src/utility/LG_qsort_3.c.gcov.html new file mode 100644 index 0000000000..77da7d8908 --- /dev/null +++ b/src/utility/LG_qsort_3.c.gcov.html @@ -0,0 +1,140 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LG_qsort_3.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LG_qsort_3.c (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:44100.0 %
Date:2024-08-29 20:08:04Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LG_qsort_3: sort a 3-by-n list of integers, using A[0:2][] as the key
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : #include "LG_internal.h"
+      19             : 
+      20             : // returns true if A [a] < B [b]
+      21             : #define LG_lt(A,a,B,b)                  \
+      22             :     LG_lt_3 (A ## _0, A ## _1, A ## _2, a, B ## _0, B ## _1, B ## _2, b)
+      23             : 
+      24             : // argument list for calling a function
+      25             : #define LG_arg(A)                       \
+      26             :     A ## _0, A ## _1, A ## _2
+      27             : 
+      28             : // argument list for calling a function, with offset
+      29             : #define LG_arg_offset(A,x)              \
+      30             :     A ## _0 + (x), A ## _1 + (x), A ## _2 + (x)
+      31             : 
+      32             : // argument list for defining a function
+      33             : #define LG_args(A)                      \
+      34             :     int64_t *LG_RESTRICT A ## _0,       \
+      35             :     int64_t *LG_RESTRICT A ## _1,       \
+      36             :     int64_t *LG_RESTRICT A ## _2
+      37             : 
+      38             : // each entry has a 3-integer key
+      39             : #define LG_K 3
+      40             : 
+      41             : // swap A [a] and A [b]
+      42             : #define LG_swap(A,a,b)                                                        \
+      43             : {                                                                             \
+      44             :     int64_t t0 = A ## _0 [a] ; A ## _0 [a] = A ## _0 [b] ; A ## _0 [b] = t0 ; \
+      45             :     int64_t t1 = A ## _1 [a] ; A ## _1 [a] = A ## _1 [b] ; A ## _1 [b] = t1 ; \
+      46             :     int64_t t2 = A ## _2 [a] ; A ## _2 [a] = A ## _2 [b] ; A ## _2 [b] = t2 ; \
+      47             : }
+      48             : 
+      49             : #define LG_partition LG_partition_3
+      50             : #define LG_quicksort LG_quicksort_3
+      51             : 
+      52             : #include "LG_qsort_template.h"
+      53             : 
+      54         169 : void LG_qsort_3     // sort array A of size 3-by-n, using 3 keys (A [0:2][])
+      55             : (
+      56             :     int64_t *LG_RESTRICT A_0,       // size n array
+      57             :     int64_t *LG_RESTRICT A_1,       // size n array
+      58             :     int64_t *LG_RESTRICT A_2,       // size n array
+      59             :     const int64_t n
+      60             : )
+      61             : {
+      62         169 :     uint64_t seed = n ;
+      63         169 :     LG_quicksort (LG_arg (A), n, &seed, NULL) ;
+      64         169 : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LG_qsort_template.h.func-sort-c.html b/src/utility/LG_qsort_template.h.func-sort-c.html new file mode 100644 index 0000000000..800eb4e83f --- /dev/null +++ b/src/utility/LG_qsort_template.h.func-sort-c.html @@ -0,0 +1,96 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LG_qsort_template.h - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LG_qsort_template.h (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:2323100.0 %
Date:2024-08-29 20:08:04Functions:66100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_partition_1a102814
LG_partition_3112526
LG_quicksort_1a205882
LG_quicksort_3225221
LG_partition_2311446
LG_quicksort_2624613
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LG_qsort_template.h.func.html b/src/utility/LG_qsort_template.h.func.html new file mode 100644 index 0000000000..010fd4b6c9 --- /dev/null +++ b/src/utility/LG_qsort_template.h.func.html @@ -0,0 +1,96 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LG_qsort_template.h - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LG_qsort_template.h (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:2323100.0 %
Date:2024-08-29 20:08:04Functions:66100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
LG_partition_1a102814
LG_partition_2311446
LG_partition_3112526
LG_quicksort_1a205882
LG_quicksort_2624613
LG_quicksort_3225221
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/LG_qsort_template.h.gcov.html b/src/utility/LG_qsort_template.h.gcov.html new file mode 100644 index 0000000000..e9921d3f2e --- /dev/null +++ b/src/utility/LG_qsort_template.h.gcov.html @@ -0,0 +1,206 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility/LG_qsort_template.h + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utility - LG_qsort_template.h (source / functions)HitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:2323100.0 %
Date:2024-08-29 20:08:04Functions:66100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : //------------------------------------------------------------------------------
+       2             : // LG_qsort_template: quicksort of a K-by-n array
+       3             : //------------------------------------------------------------------------------
+       4             : 
+       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
+       6             : // SPDX-License-Identifier: BSD-2-Clause
+       7             : //
+       8             : // For additional details (including references to third party source code and
+       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
+      10             : // Contributors.txt for a full list of contributors. Created, in part, with
+      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
+      12             : // DM22-0790
+      13             : 
+      14             : // Contributed by Timothy A. Davis, Texas A&M University
+      15             : 
+      16             : //------------------------------------------------------------------------------
+      17             : 
+      18             : // This file is #include'd in LG_qsort*.c to create specific versions for
+      19             : // different kinds of sort keys and auxiliary arrays.  Requires an inline or
+      20             : // macro definition of the LG_lt function.  The LG_lt function has the form
+      21             : // LG_lt (A,i,B,j) and returns true if A[i] < B[j].
+      22             : 
+      23             : // All of these functions are static; there will be versions of them in each
+      24             : // variant of LG_qsort*, and given unique names via #define's in the
+      25             : // #include'ing file.
+      26             : 
+      27             : //------------------------------------------------------------------------------
+      28             : // LG_partition: use a pivot to partition an array
+      29             : //------------------------------------------------------------------------------
+      30             : 
+      31             : // C.A.R Hoare partition method, partitions an array in-place via a pivot.
+      32             : // k = partition (A, n) partitions A [0:n-1] such that all entries in
+      33             : // A [0:k] are <= all entries in A [k+1:n-1].
+      34             : 
+      35      526786 : static inline int64_t LG_partition
+      36             : (
+      37             :     LG_args (A),            // array(s) to partition
+      38             :     const int64_t n,        // size of the array(s) to partition
+      39             :     uint64_t *seed,         // random number seed, modified on output
+      40             :     LG_void *tx
+      41             : )
+      42             : {
+      43             : 
+      44             :     // select a pivot at random
+      45      526786 :     int64_t pivot = ((n < LG_RANDOM15_MAX) ?
+      46      526786 :         LG_Random15 (seed) : LG_Random60 (seed)) % n ;
+      47             : 
+      48             :     // get the Pivot
+      49      526786 :     int64_t Pivot_0 [1] ; Pivot_0 [0] = A_0 [pivot] ;
+      50             :     #if LG_K > 1
+      51      423972 :     int64_t Pivot_1 [1] ; Pivot_1 [0] = A_1 [pivot] ;
+      52             :     #endif
+      53             :     #if LG_K > 2
+      54      112526 :     int64_t Pivot_2 [1] ; Pivot_2 [0] = A_2 [pivot] ;
+      55             :     #endif
+      56             : 
+      57             :     // At the top of the while loop, A [left+1...right-1] is considered, and
+      58             :     // entries outside this range are in their proper place and not touched.
+      59             :     // Since the input specification of this function is to partition A
+      60             :     // [0..n-1], left must start at -1 and right must start at n.
+      61      526786 :     int64_t left = -1 ;
+      62      526786 :     int64_t right = n ;
+      63             : 
+      64             :     // keep partitioning until the left and right sides meet
+      65    13413610 :     while (true)
+      66             :     {
+      67             :         // loop invariant:  A [0..left] < pivot and A [right..n-1] > pivot,
+      68             :         // so the region to be considered is A [left+1 ... right-1].
+      69             : 
+      70             :         // increment left until finding an entry A [left] >= pivot
+      71    39729138 :         do { left++ ; } while (LG_lt (A, left, Pivot, 0)) ;
+      72             : 
+      73             :         // decrement right until finding an entry A [right] <= pivot
+      74    41263801 :         do { right-- ; } while (LG_lt (Pivot, 0, A, right)) ;
+      75             : 
+      76             :         // now A [0..left-1] < pivot and A [right+1..n-1] > pivot, but
+      77             :         // A [left] > pivot and A [right] < pivot, so these two entries
+      78             :         // are out of place and must be swapped.
+      79             : 
+      80             :         // However, if the two sides have met, the partition is finished.
+      81    13940396 :         if (left >= right)
+      82             :         {
+      83             :             // A has been partitioned into A [0:right] and A [right+1:n-1].
+      84             :             // k = right+1, so A is split into A [0:k-1] and A [k:n-1].
+      85      526786 :             return (right + 1) ;
+      86             :         }
+      87             : 
+      88             :         // since A [left] > pivot and A [right] < pivot, swap them
+      89    13413610 :         LG_swap (A, left, right) ;
+      90             : 
+      91             :         // after the swap this condition holds:
+      92             :         // A [0..left] < pivot and A [right..n-1] > pivot
+      93             :     }
+      94             : }
+      95             : 
+      96             : //------------------------------------------------------------------------------
+      97             : // LG_quicksort: recursive single-threaded quicksort
+      98             : //------------------------------------------------------------------------------
+      99             : 
+     100     1055716 : static void LG_quicksort    // sort A [0:n-1]
+     101             : (
+     102             :     LG_args (A),            // array(s) to sort
+     103             :     const int64_t n,        // size of the array(s) to sort
+     104             :     uint64_t *seed,         // random number seed
+     105             :     LG_void *tx
+     106             : )
+     107             : {
+     108             : 
+     109     1055716 :     if (n < 20)
+     110             :     {
+     111             :         // in-place insertion sort on A [0:n-1], where n is small
+     112     5852040 :         for (int64_t k = 1 ; k < n ; k++)
+     113             :         {
+     114    13505041 :             for (int64_t j = k ; j > 0 && LG_lt (A, j, A, j-1) ; j--)
+     115             :             {
+     116             :                 // swap A [j-1] and A [j]
+     117     8181931 :                 LG_swap (A, j-1, j) ;
+     118             :             }
+     119             :         }
+     120             :     }
+     121             :     else
+     122             :     {
+     123             :         // partition A [0:n-1] into A [0:k-1] and A [k:n-1]
+     124      526786 :         int64_t k = LG_partition (LG_arg (A), n, seed, tx) ;
+     125             : 
+     126             :         // sort each partition
+     127      526786 :         LG_quicksort (LG_arg (A), k, seed, tx) ;             // sort A [0:k-1]
+     128      526786 :         LG_quicksort (LG_arg_offset (A, k), n-k, seed, tx) ; // sort A [k+1:n-1]
+     129             :     }
+     130     1055716 : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/index-sort-f.html b/src/utility/index-sort-f.html new file mode 100644 index 0000000000..07c2b0f568 --- /dev/null +++ b/src/utility/index-sort-f.html @@ -0,0 +1,593 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utilityHitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:17251725100.0 %
Date:2024-08-29 20:08:04Functions:100100100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
LAGraph_SizeOfType.c +
100.0%
+
100.0 %6 / 6100.0 %1 / 1
LAGraph_CheckGraph.c +
100.0%
+
100.0 %33 / 33100.0 %1 / 1
LAGraph_Matrix_IsEqualOp.c +
100.0%
+
100.0 %29 / 29100.0 %1 / 1
LAGraph_GetNumThreads.c +
100.0%
+
100.0 %6 / 6100.0 %1 / 1
LAGraph_Delete.c +
100.0%
+
100.0 %8 / 8100.0 %1 / 1
LAGraph_Finalize.c +
100.0%
+
100.0 %45 / 45100.0 %1 / 1
LAGraph_DeleteSelfEdges.c +
100.0%
+
100.0 %10 / 10100.0 %1 / 1
LAGraph_NameOfType.c +
100.0%
+
100.0 %18 / 18100.0 %1 / 1
LAGraph_Realloc.c +
100.0%
+
100.0 %25 / 25100.0 %1 / 1
LAGraph_SetNumThreads.c +
100.0%
+
100.0 %8 / 8100.0 %1 / 1
LAGraph_Vector_IsEqual.c +
100.0%
+
100.0 %46 / 46100.0 %1 / 1
LAGraph_WallClockTime.c +
100.0%
+
100.0 %6 / 6100.0 %1 / 1
LAGraph_TypeFromName.c +
100.0%
+
100.0 %5 / 5100.0 %1 / 1
LAGraph_Matrix_Structure.c +
100.0%
+
100.0 %10 / 10100.0 %1 / 1
LAGraph_Matrix_IsEqual.c +
100.0%
+
100.0 %48 / 48100.0 %1 / 1
LG_qsort_3.c +
100.0%
+
100.0 %4 / 4100.0 %1 / 1
LAGraph_Cached_OutDegree.c +
100.0%
+
100.0 %15 / 15100.0 %1 / 1
LAGraph_New.c +
100.0%
+
100.0 %22 / 22100.0 %1 / 1
LAGraph_Cached_NSelfEdges.c +
100.0%
+
100.0 %5 / 5100.0 %1 / 1
LAGr_SortByDegree.c +
100.0%
+
100.0 %38 / 38100.0 %1 / 1
LAGraph_Cached_AT.c +
100.0%
+
100.0 %16 / 16100.0 %1 / 1
LAGr_SampleDegree.c +
100.0%
+
100.0 %27 / 27100.0 %1 / 1
LAGraph_DeleteCached.c +
100.0%
+
100.0 %16 / 16100.0 %1 / 1
LAGraph_Cached_IsSymmetricStructure.c +
100.0%
+
100.0 %24 / 24100.0 %1 / 1
LAGraph_Malloc.c +
100.0%
+
100.0 %10 / 10100.0 %1 / 1
LAGraph_Graph_Print.c +
100.0%
+
100.0 %39 / 39100.0 %1 / 1
LAGraph_Init.c +
100.0%
+
100.0 %3 / 3100.0 %1 / 1
LAGraph_Cached_EMin.c +
100.0%
+
100.0 %23 / 23100.0 %1 / 1
LG_nself_edges.c +
100.0%
+
100.0 %15 / 15100.0 %1 / 1
LAGraph_Vector_Structure.c +
100.0%
+
100.0 %9 / 9100.0 %1 / 1
LAGraph_Vector_IsEqualOp.c +
100.0%
+
100.0 %27 / 27100.0 %1 / 1
LG_qsort_1a.c +
100.0%
+
100.0 %4 / 4100.0 %1 / 1
LAGraph_Calloc.c +
100.0%
+
100.0 %14 / 14100.0 %1 / 1
LG_KindName.c +
100.0%
+
100.0 %9 / 9100.0 %1 / 1
LAGraph_Cached_EMax.c +
100.0%
+
100.0 %23 / 23100.0 %1 / 1
LAGraph_Version.c +
100.0%
+
100.0 %9 / 9100.0 %1 / 1
LAGraph_Cached_InDegree.c +
100.0%
+
100.0 %21 / 21100.0 %1 / 1
LG_qsort_2.c +
100.0%
+
100.0 %4 / 4100.0 %1 / 1
LAGraph_Free.c +
100.0%
+
100.0 %6 / 6100.0 %1 / 1
LG_Random.c +
100.0%
+
100.0 %10 / 10100.0 %2 / 2
LG_internal.h +
100.0%
+
100.0 %16 / 16100.0 %2 / 2
LAGraph_MMWrite.c +
100.0%
+
100.0 %166 / 166100.0 %2 / 2
LAGr_Init.c +
100.0%
+
100.0 %62 / 62100.0 %3 / 3
LAGraph_TypeName.c +
100.0%
+
100.0 %12 / 12100.0 %3 / 3
LG_msort2.c +
100.0%
+
100.0 %113 / 113100.0 %4 / 4
LG_msort3.c +
100.0%
+
100.0 %119 / 119100.0 %4 / 4
LG_msort1.c +
100.0%
+
100.0 %107 / 107100.0 %4 / 4
LG_qsort_template.h +
100.0%
+
100.0 %23 / 23100.0 %6 / 6
LAGraph_MMRead.c +
100.0%
+
100.0 %332 / 332100.0 %7 / 7
LAGraph_Vector_Print.c +
100.0%
+
100.0 %40 / 40100.0 %12 / 12
LAGraph_Matrix_Print.c +
100.0%
+
100.0 %39 / 39100.0 %12 / 12
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/index-sort-l.html b/src/utility/index-sort-l.html new file mode 100644 index 0000000000..d82ebd0655 --- /dev/null +++ b/src/utility/index-sort-l.html @@ -0,0 +1,593 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utilityHitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:17251725100.0 %
Date:2024-08-29 20:08:04Functions:100100100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
LAGraph_Init.c +
100.0%
+
100.0 %3 / 3100.0 %1 / 1
LG_qsort_3.c +
100.0%
+
100.0 %4 / 4100.0 %1 / 1
LG_qsort_1a.c +
100.0%
+
100.0 %4 / 4100.0 %1 / 1
LG_qsort_2.c +
100.0%
+
100.0 %4 / 4100.0 %1 / 1
LAGraph_TypeFromName.c +
100.0%
+
100.0 %5 / 5100.0 %1 / 1
LAGraph_Cached_NSelfEdges.c +
100.0%
+
100.0 %5 / 5100.0 %1 / 1
LAGraph_SizeOfType.c +
100.0%
+
100.0 %6 / 6100.0 %1 / 1
LAGraph_GetNumThreads.c +
100.0%
+
100.0 %6 / 6100.0 %1 / 1
LAGraph_WallClockTime.c +
100.0%
+
100.0 %6 / 6100.0 %1 / 1
LAGraph_Free.c +
100.0%
+
100.0 %6 / 6100.0 %1 / 1
LAGraph_Delete.c +
100.0%
+
100.0 %8 / 8100.0 %1 / 1
LAGraph_SetNumThreads.c +
100.0%
+
100.0 %8 / 8100.0 %1 / 1
LAGraph_Vector_Structure.c +
100.0%
+
100.0 %9 / 9100.0 %1 / 1
LG_KindName.c +
100.0%
+
100.0 %9 / 9100.0 %1 / 1
LAGraph_Version.c +
100.0%
+
100.0 %9 / 9100.0 %1 / 1
LAGraph_DeleteSelfEdges.c +
100.0%
+
100.0 %10 / 10100.0 %1 / 1
LAGraph_Matrix_Structure.c +
100.0%
+
100.0 %10 / 10100.0 %1 / 1
LG_Random.c +
100.0%
+
100.0 %10 / 10100.0 %2 / 2
LAGraph_Malloc.c +
100.0%
+
100.0 %10 / 10100.0 %1 / 1
LAGraph_TypeName.c +
100.0%
+
100.0 %12 / 12100.0 %3 / 3
LAGraph_Calloc.c +
100.0%
+
100.0 %14 / 14100.0 %1 / 1
LAGraph_Cached_OutDegree.c +
100.0%
+
100.0 %15 / 15100.0 %1 / 1
LG_nself_edges.c +
100.0%
+
100.0 %15 / 15100.0 %1 / 1
LAGraph_Cached_AT.c +
100.0%
+
100.0 %16 / 16100.0 %1 / 1
LAGraph_DeleteCached.c +
100.0%
+
100.0 %16 / 16100.0 %1 / 1
LG_internal.h +
100.0%
+
100.0 %16 / 16100.0 %2 / 2
LAGraph_NameOfType.c +
100.0%
+
100.0 %18 / 18100.0 %1 / 1
LAGraph_Cached_InDegree.c +
100.0%
+
100.0 %21 / 21100.0 %1 / 1
LAGraph_New.c +
100.0%
+
100.0 %22 / 22100.0 %1 / 1
LG_qsort_template.h +
100.0%
+
100.0 %23 / 23100.0 %6 / 6
LAGraph_Cached_EMin.c +
100.0%
+
100.0 %23 / 23100.0 %1 / 1
LAGraph_Cached_EMax.c +
100.0%
+
100.0 %23 / 23100.0 %1 / 1
LAGraph_Cached_IsSymmetricStructure.c +
100.0%
+
100.0 %24 / 24100.0 %1 / 1
LAGraph_Realloc.c +
100.0%
+
100.0 %25 / 25100.0 %1 / 1
LAGr_SampleDegree.c +
100.0%
+
100.0 %27 / 27100.0 %1 / 1
LAGraph_Vector_IsEqualOp.c +
100.0%
+
100.0 %27 / 27100.0 %1 / 1
LAGraph_Matrix_IsEqualOp.c +
100.0%
+
100.0 %29 / 29100.0 %1 / 1
LAGraph_CheckGraph.c +
100.0%
+
100.0 %33 / 33100.0 %1 / 1
LAGr_SortByDegree.c +
100.0%
+
100.0 %38 / 38100.0 %1 / 1
LAGraph_Matrix_Print.c +
100.0%
+
100.0 %39 / 39100.0 %12 / 12
LAGraph_Graph_Print.c +
100.0%
+
100.0 %39 / 39100.0 %1 / 1
LAGraph_Vector_Print.c +
100.0%
+
100.0 %40 / 40100.0 %12 / 12
LAGraph_Finalize.c +
100.0%
+
100.0 %45 / 45100.0 %1 / 1
LAGraph_Vector_IsEqual.c +
100.0%
+
100.0 %46 / 46100.0 %1 / 1
LAGraph_Matrix_IsEqual.c +
100.0%
+
100.0 %48 / 48100.0 %1 / 1
LAGr_Init.c +
100.0%
+
100.0 %62 / 62100.0 %3 / 3
LG_msort1.c +
100.0%
+
100.0 %107 / 107100.0 %4 / 4
LG_msort2.c +
100.0%
+
100.0 %113 / 113100.0 %4 / 4
LG_msort3.c +
100.0%
+
100.0 %119 / 119100.0 %4 / 4
LAGraph_MMWrite.c +
100.0%
+
100.0 %166 / 166100.0 %2 / 2
LAGraph_MMRead.c +
100.0%
+
100.0 %332 / 332100.0 %7 / 7
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/src/utility/index.html b/src/utility/index.html new file mode 100644 index 0000000000..d3400dea44 --- /dev/null +++ b/src/utility/index.html @@ -0,0 +1,593 @@ + + + + + + + LCOV - LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57Z - src/utility + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - src/utilityHitTotalCoverage
Test:LAGraph code coverage report. Commit id: 1bd0c3d. Current time (UTC): 2024-08-29T20:05:57ZLines:17251725100.0 %
Date:2024-08-29 20:08:04Functions:100100100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
LAGr_Init.c +
100.0%
+
100.0 %62 / 62100.0 %3 / 3
LAGr_SampleDegree.c +
100.0%
+
100.0 %27 / 27100.0 %1 / 1
LAGr_SortByDegree.c +
100.0%
+
100.0 %38 / 38100.0 %1 / 1
LAGraph_Cached_AT.c +
100.0%
+
100.0 %16 / 16100.0 %1 / 1
LAGraph_Cached_EMax.c +
100.0%
+
100.0 %23 / 23100.0 %1 / 1
LAGraph_Cached_EMin.c +
100.0%
+
100.0 %23 / 23100.0 %1 / 1
LAGraph_Cached_InDegree.c +
100.0%
+
100.0 %21 / 21100.0 %1 / 1
LAGraph_Cached_IsSymmetricStructure.c +
100.0%
+
100.0 %24 / 24100.0 %1 / 1
LAGraph_Cached_NSelfEdges.c +
100.0%
+
100.0 %5 / 5100.0 %1 / 1
LAGraph_Cached_OutDegree.c +
100.0%
+
100.0 %15 / 15100.0 %1 / 1
LAGraph_Calloc.c +
100.0%
+
100.0 %14 / 14100.0 %1 / 1
LAGraph_CheckGraph.c +
100.0%
+
100.0 %33 / 33100.0 %1 / 1
LAGraph_Delete.c +
100.0%
+
100.0 %8 / 8100.0 %1 / 1
LAGraph_DeleteCached.c +
100.0%
+
100.0 %16 / 16100.0 %1 / 1
LAGraph_DeleteSelfEdges.c +
100.0%
+
100.0 %10 / 10100.0 %1 / 1
LAGraph_Finalize.c +
100.0%
+
100.0 %45 / 45100.0 %1 / 1
LAGraph_Free.c +
100.0%
+
100.0 %6 / 6100.0 %1 / 1
LAGraph_GetNumThreads.c +
100.0%
+
100.0 %6 / 6100.0 %1 / 1
LAGraph_Graph_Print.c +
100.0%
+
100.0 %39 / 39100.0 %1 / 1
LAGraph_Init.c +
100.0%
+
100.0 %3 / 3100.0 %1 / 1
LAGraph_MMRead.c +
100.0%
+
100.0 %332 / 332100.0 %7 / 7
LAGraph_MMWrite.c +
100.0%
+
100.0 %166 / 166100.0 %2 / 2
LAGraph_Malloc.c +
100.0%
+
100.0 %10 / 10100.0 %1 / 1
LAGraph_Matrix_IsEqual.c +
100.0%
+
100.0 %48 / 48100.0 %1 / 1
LAGraph_Matrix_IsEqualOp.c +
100.0%
+
100.0 %29 / 29100.0 %1 / 1
LAGraph_Matrix_Print.c +
100.0%
+
100.0 %39 / 39100.0 %12 / 12
LAGraph_Matrix_Structure.c +
100.0%
+
100.0 %10 / 10100.0 %1 / 1
LAGraph_NameOfType.c +
100.0%
+
100.0 %18 / 18100.0 %1 / 1
LAGraph_New.c +
100.0%
+
100.0 %22 / 22100.0 %1 / 1
LAGraph_Realloc.c +
100.0%
+
100.0 %25 / 25100.0 %1 / 1
LAGraph_SetNumThreads.c +
100.0%
+
100.0 %8 / 8100.0 %1 / 1
LAGraph_SizeOfType.c +
100.0%
+
100.0 %6 / 6100.0 %1 / 1
LAGraph_TypeFromName.c +
100.0%
+
100.0 %5 / 5100.0 %1 / 1
LAGraph_TypeName.c +
100.0%
+
100.0 %12 / 12100.0 %3 / 3
LAGraph_Vector_IsEqual.c +
100.0%
+
100.0 %46 / 46100.0 %1 / 1
LAGraph_Vector_IsEqualOp.c +
100.0%
+
100.0 %27 / 27100.0 %1 / 1
LAGraph_Vector_Print.c +
100.0%
+
100.0 %40 / 40100.0 %12 / 12
LAGraph_Vector_Structure.c +
100.0%
+
100.0 %9 / 9100.0 %1 / 1
LAGraph_Version.c +
100.0%
+
100.0 %9 / 9100.0 %1 / 1
LAGraph_WallClockTime.c +
100.0%
+
100.0 %6 / 6100.0 %1 / 1
LG_KindName.c +
100.0%
+
100.0 %9 / 9100.0 %1 / 1
LG_Random.c +
100.0%
+
100.0 %10 / 10100.0 %2 / 2
LG_internal.h +
100.0%
+
100.0 %16 / 16100.0 %2 / 2
LG_msort1.c +
100.0%
+
100.0 %107 / 107100.0 %4 / 4
LG_msort2.c +
100.0%
+
100.0 %113 / 113100.0 %4 / 4
LG_msort3.c +
100.0%
+
100.0 %119 / 119100.0 %4 / 4
LG_nself_edges.c +
100.0%
+
100.0 %15 / 15100.0 %1 / 1
LG_qsort_1a.c +
100.0%
+
100.0 %4 / 4100.0 %1 / 1
LG_qsort_2.c +
100.0%
+
100.0 %4 / 4100.0 %1 / 1
LG_qsort_3.c +
100.0%
+
100.0 %4 / 4100.0 %1 / 1
LG_qsort_template.h +
100.0%
+
100.0 %23 / 23100.0 %6 / 6
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/updown.png b/updown.png new file mode 100644 index 0000000000000000000000000000000000000000..aa56a238b3e6c435265250f9266cd1b8caba0f20 GIT binary patch literal 117 zcmeAS@N?(olHy`uVBq!ia0vp^AT}Qd8;}%R+`Ae`*?77*hG?8mPH5^{)z4*}Q$iB}huR`+ literal 0 HcmV?d00001