Skip to content

Commit 89f8031

Browse files
maxflow: more simplifications for the paper
1 parent a1074c5 commit 89f8031

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

experimental/algorithm/LAGr_MaxFlow.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ static GrB_Info LG_augment_maxflow
123123
GrB_free(&residual_vec); \
124124
GrB_free(&MakeFlow); \
125125
GrB_free(&GetResidual); \
126+
GrB_free(&lvl) ; \
127+
LAGraph_Delete(&G2, msg); \
126128
}
127129

128130
#define LG_FREE_ALL \
@@ -561,7 +563,7 @@ int LAGr_MaxFlow
561563
GrB_Vector lvl = NULL ;
562564
GrB_UnaryOp GetResidual = NULL ;
563565
GrB_Matrix C = NULL, T = NULL ;
564-
LAGraph_Graph res_graph = NULL ;
566+
LAGraph_Graph G2 = NULL ;
565567

566568
// to create R
567569
GrB_UnaryOp CreateResidualForward = NULL, CreateResidualBackward = NULL ;
@@ -924,13 +926,13 @@ int LAGr_MaxFlow
924926
GRB_TRY(GrB_select(C, NULL, NULL, GrB_VALUEGT_FP64, C, 0, NULL)) ;
925927
// T = C'
926928
GRB_TRY(GrB_transpose(T, NULL, NULL, C, NULL));
927-
// construct the res_graph and its cached transpose and outdegree
928-
LG_TRY(LAGraph_New(&res_graph, &T, LAGraph_ADJACENCY_DIRECTED, msg));
929-
res_graph->AT = C ;
929+
// construct G2 and its cached transpose and outdegree
930+
LG_TRY(LAGraph_New(&G2, &T, LAGraph_ADJACENCY_DIRECTED, msg));
931+
G2->AT = C ;
930932
C = NULL ;
931-
LG_TRY(LAGraph_Cached_OutDegree(res_graph, msg));
932-
// compute lvl using bfs on res_graph, starting at sink node
933-
LG_TRY(LAGr_BreadthFirstSearch(&lvl, NULL, res_graph, sink, msg));
933+
LG_TRY(LAGraph_Cached_OutDegree(G2, msg));
934+
// compute lvl using bfs on G2, starting at sink node
935+
LG_TRY(LAGr_BreadthFirstSearch(&lvl, NULL, G2, sink, msg));
934936

935937
// d<!struct([src,sink])> = lvl
936938
GRB_TRY(GrB_assign(d, src_and_sink, NULL, lvl, GrB_ALL, n, GrB_DESC_SC));
@@ -956,7 +958,7 @@ int LAGr_MaxFlow
956958
}
957959

958960
GrB_free(&lvl);
959-
LG_TRY(LAGraph_Delete(&res_graph, msg));
961+
LG_TRY(LAGraph_Delete(&G2, msg));
960962
GRB_TRY(GrB_Vector_nvals(&n_active, e));
961963
if(n_active == 0){
962964
break;

0 commit comments

Comments
 (0)