Skip to content

Commit ae95549

Browse files
committed
modified initialization of flows
1 parent 84a120e commit ae95549

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

experimental/algorithm/LAGr_MaxFlow.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ int LAGr_MaxFlow(double* f, LAGraph_Graph G, GrB_Index src, GrB_Index sink, char
590590
//active_set and n_active
591591
//GrB_Vector active_set = NULL ;
592592
GrB_Vector src_and_sink = NULL ;
593-
GrB_Index n_active ;
593+
GrB_Index n_active = INT32_MAX ;
594594

595595
//semiring and vectors for y<e, struct> = R x d
596596
GrB_Vector y = NULL ;
@@ -707,10 +707,12 @@ int LAGr_MaxFlow(double* f, LAGraph_Graph G, GrB_Index src, GrB_Index sink, char
707707
GrB_FlowEdge, GrB_FP64, "MF_MakeFlow", GRB_MAKEF_STR));
708708
GRB_TRY(GrB_Vector_new(&Re, GrB_FlowEdge, n));
709709
GRB_TRY(GrB_Vector_new(&e, GrB_FP64, n));
710+
#if 0
710711
GRB_TRY(GrB_extract(e, NULL, NULL, A, GrB_ALL, n, src, GrB_DESC_T0));
711712
GRB_TRY(GrB_apply(Re, NULL, NULL, GrB_MakeFlow, e, NULL));
712713
GRB_TRY(GrB_assign(R, NULL, GrB_InitForwardFlows, Re, src, GrB_ALL, n, NULL));
713714
GRB_TRY(GrB_assign(R, NULL, GrB_InitBackwardFlows, Re, GrB_ALL, n, src, NULL));
715+
#endif
714716

715717
//extract n_active from e masking sink and src then assign to e
716718
//GRB_TRY(GrB_Vector_new(&active_set, GrB_FP64, n));
@@ -719,8 +721,8 @@ int LAGr_MaxFlow(double* f, LAGraph_Graph G, GrB_Index src, GrB_Index sink, char
719721
GRB_TRY (GrB_Vector_setElement (src_and_sink, true, src)) ;
720722

721723
// augment maxflow if the edge (src,sink) exists
722-
LG_TRY (LG_augment_maxflow (f, e, sink, src_and_sink,
723-
/* active_set, */ &n_active, /* n, */ msg)) ;
724+
//LG_TRY (LG_augment_maxflow (f, e, sink, src_and_sink,
725+
// /* active_set, */ &n_active, /* n, */ msg)) ;
724726
//create flow vec
725727
GRB_TRY(GrB_Vector_new(&residual_vec, GrB_FP64, n));
726728

@@ -953,7 +955,17 @@ int LAGr_MaxFlow(double* f, LAGraph_Graph G, GrB_Index src, GrB_Index sink, char
953955
NULL, GrB_VALUEGT_FP64, /* FLOP */
954956
e, -1, NULL));
955957
#else
956-
GrB_assign (e, lvl, NULL, empty, GrB_ALL, n, GrB_DESC_SC) ;
958+
if(iter == 0){
959+
GRB_TRY(GrB_extract(e, lvl, NULL, A, GrB_ALL, n, src, GrB_DESC_ST0));
960+
GRB_TRY(GrB_apply(Re, NULL, NULL, GrB_MakeFlow, e, NULL));
961+
GRB_TRY(GrB_assign(R, NULL, GrB_InitForwardFlows, Re, src, GrB_ALL, n, NULL));
962+
GRB_TRY(GrB_assign(R, NULL, GrB_InitBackwardFlows, Re, GrB_ALL, n, src, NULL));
963+
LG_TRY (LG_augment_maxflow (f, e, sink, src_and_sink,
964+
/* active_set, */ &n_active, /* n, */ msg)) ;
965+
}
966+
else{
967+
GrB_assign (e, lvl, NULL, empty, GrB_ALL, n, GrB_DESC_SC) ;
968+
}
957969
#endif
958970
// ]
959971

0 commit comments

Comments
 (0)