Skip to content

Commit d9ae471

Browse files
SwapEdges: recompute n_keep, and return num_swaps
1 parent 4ca630d commit d9ae471

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ See <https://github.com/GraphBLAS/LAGraph> for the source code for LAGraph,
1010
Documenation is at <https://lagraph.readthedocs.org>.
1111
Test coverage results are at <https://graphblas.org/LAGraph>.
1212

13-
Currently, SuiteSparse:GraphBLAS v7.0.0 or later is required. However, use the
13+
Currently, SuiteSparse:GraphBLAS v9.0.0 or later is required. However, use the
1414
latest stable release of SuiteSparse:GraphBLAS for best results.
1515
See <https://github.com/DrTimothyAldenDavis/GraphBLAS>
1616

experimental/algorithm/LAGr_SwapEdges.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -765,16 +765,20 @@ int LAGr_SwapEdges
765765
GRB_TRY (GxB_unload_Vector_into_Container(M, con, NULL)) ;
766766
GRB_TRY (GrB_free(&(con->b))) ;
767767
con->b = dup_swaps_v;
768+
// n_keep = sum (dup_swaps_v), to count the # of 1's that now appear in
769+
// dup_swaps_v, which will become nvals(M) after loading M from the
770+
// container con.
771+
GRB_TRY (GrB_reduce (&n_keep, NULL, GrB_PLUS_MONOID_UINT64,
772+
dup_swaps_v, NULL)) ;
768773
con->nvals = n_keep;
769774
con->format = GxB_BITMAP;
770775
dup_swaps_v = NULL;
771776
GRB_TRY (GxB_load_Vector_from_Container(M, con, NULL)) ;
772-
GRB_TRY (GxB_print (M, 1)) ; // FIXME: added for debugging
777+
// GRB_TRY (GxB_print (M, 1)) ; // for debugging; must be OK here
773778
GRB_TRY (GrB_free(&con)) ;
774779
GRB_TRY (LAGraph_FastAssign_Semiring(
775780
E_vec, NULL, second_edge, edge_perm, M, ramp_v,
776781
second_second_edge, NULL, msg)) ;
777-
778782

779783
n_keep /= 2;
780784

@@ -811,6 +815,7 @@ GRB_TRY (GxB_print (M, 1)) ; // FIXME: added for debugging
811815
LAGRAPH_TRY (LAGraph_New (
812816
G_new, &A_new, LAGraph_ADJACENCY_UNDIRECTED, msg)) ;
813817
LG_FREE_WORK ;
818+
(*pSwaps) = num_swaps ;
814819
return (num_swaps >= totSwaps)? GrB_SUCCESS : LAGRAPH_INSUFFICIENT_SWAPS ;
815820
#else
816821
// printf("LAGr_SwapEdges Needs GB v10\n") ;

0 commit comments

Comments
 (0)