Skip to content

Commit 1fa989f

Browse files
maxflow: only for GrB 10.0.0 or later
1 parent a508e08 commit 1fa989f

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

experimental/algorithm/LAGr_MaxFlow.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,33 @@
1+
//------------------------------------------------------------------------------
2+
// LAGr_MaxFlow: max flow
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 [email protected]. 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 Darin Peries and Tim Davis, Texas A&M University
15+
16+
//------------------------------------------------------------------------------
117

218
#include <LAGraphX.h>
319
#include "LG_internal.h"
420
#include <LAGraph.h>
521

22+
#if LG_SUITESPARSE_GRAPHBLAS_V10
23+
624
//------------------------------------------------------------------------------
725
// LG_augment_maxflow
826
//------------------------------------------------------------------------------
927

1028
// LG_augment_maxflow is a function used to sum the current excess flow of the
1129
// sink into the output variable f for each iteration.
1230

13-
1431
#undef LG_FREE_ALL
1532
#define LG_FREE_ALL ;
1633

@@ -450,13 +467,16 @@ JIT_STR(void MF_getResidual(double * res, const MF_flowEdge * flow_edge){
450467
JIT_STR(void MF_extractMatrixFlow(double* flow, const MF_flowEdge* edge){*flow = edge->flow;}, GRB_EMFLOW_STR)
451468

452469

470+
#endif
453471

454472
//------------------------------------------------------------------------------
455473
// LAGraph_MaxFlow
456474
//------------------------------------------------------------------------------
457475

458476
int LAGr_MaxFlow(double* f, GrB_Matrix* flow_mtx, LAGraph_Graph G, GrB_Index src, GrB_Index sink, char *msg){
459477

478+
#if LG_SUITESPARSE_GRAPHBLAS_V10
479+
460480
//types
461481
GrB_Type GrB_FlowEdge = NULL ;
462482
GrB_Type GrB_ResultTuple = NULL ;
@@ -930,4 +950,7 @@ int LAGr_MaxFlow(double* f, GrB_Matrix* flow_mtx, LAGraph_Graph G, GrB_Index src
930950

931951
LG_FREE_ALL;
932952
return GrB_SUCCESS;
953+
#else
954+
return GrB_NOT_IMPLEMENTED ;
955+
#endif
933956
}

experimental/algorithm/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
* LAGraph_msf: Minimum spanning forest
2323
* LAGraph_scc: Strongly connected components
2424

25+
* LAGraph_MaxFlow: maximum flow
26+
2527
* LAGraph_AllKCore: all K-cores of a graph
2628
* LAGraph_KCore: a single K-core of a graph
2729
* LAGraph_KCoreDecompose:

experimental/test/test_MaxFlow.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
//------------------------------------------------------------------------------
2+
// experimental/test/test_MaxFlow: tests for LAGr_MaxFlow
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 [email protected]. 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 Darin Peries and Tim Davis, Texas A&M University
15+
16+
//------------------------------------------------------------------------------
117

218
#include <acutest.h>
319
#include <LAGraphX.h>
@@ -34,6 +50,7 @@ test_info tests[] = {
3450
//399 11098623877 alt sink and src for test 6
3551

3652
void test_MaxFlow(void) {
53+
#if LG_SUITESPARSE_GRAPHBLAS_V10
3754
LAGraph_Init(msg);
3855
//OK(LG_SET_BURBLE(1));
3956
OK(LG_SET_BURBLE(0));
@@ -61,10 +78,12 @@ void test_MaxFlow(void) {
6178
OK(LAGraph_Delete(&G, msg));
6279
}
6380
LAGraph_Finalize(msg);
81+
#endif
6482
}
6583

6684
void test_MaxFlowMtx(void) {
6785
LAGraph_Init(msg);
86+
#if LG_SUITESPARSE_GRAPHBLAS_V10
6887
//OK(LG_SET_BURBLE(1));
6988
OK(LG_SET_BURBLE(0));
7089
OK(GxB_Global_Option_set(GxB_JIT_C_CONTROL, 4));
@@ -100,6 +119,7 @@ void test_MaxFlowMtx(void) {
100119
GrB_free(&flow_mtx);
101120
OK(LAGraph_Delete(&G, msg));
102121
}
122+
#endif
103123
LAGraph_Finalize(msg);
104124
}
105125

0 commit comments

Comments
 (0)