src/test/preflow_test.cc
changeset 842 a4bb28813570
parent 833 512e5fd7d38b
child 845 e4692f92a79b
equal deleted inserted replaced
0:5680275c2d2d 1:3633b1c6f309
    55 
    55 
    56 int main() {
    56 int main() {
    57 
    57 
    58   typedef SmartGraph Graph;
    58   typedef SmartGraph Graph;
    59   
    59   
       
    60   typedef Graph::Node Node;
    60   typedef Graph::NodeIt NodeIt;
    61   typedef Graph::NodeIt NodeIt;
    61   typedef Graph::EdgeIt EdgeIt;
    62   typedef Graph::EdgeIt EdgeIt;
    62   typedef Graph::EdgeMap<int> CapMap;
    63   typedef Graph::EdgeMap<int> CapMap;
    63   typedef Graph::EdgeMap<int> FlowMap;
    64   typedef Graph::EdgeMap<int> FlowMap;
    64   typedef Graph::NodeMap<bool> CutMap;
    65   typedef Graph::NodeMap<bool> CutMap;
    66   typedef Preflow<Graph, int> PType;
    67   typedef Preflow<Graph, int> PType;
    67 
    68 
    68   std::ifstream file("preflow_graph");
    69   std::ifstream file("preflow_graph");
    69   
    70   
    70   Graph G;
    71   Graph G;
    71   NodeIt s, t;
    72   Node s, t;
    72   CapMap cap(G);
    73   CapMap cap(G);
    73   readDimacs(file, G, cap, s, t);
    74   readDimacs(file, G, cap, s, t);
    74 
    75 
    75   FlowMap flow(G,0);
    76   FlowMap flow(G,0);
    76  
    77  
    98   int flow_value=preflow_test.flowValue();
    99   int flow_value=preflow_test.flowValue();
    99 
   100 
   100 
   101 
   101   for(EdgeIt e(G); e!=INVALID; ++e) cap[e]=2*cap[e]; 
   102   for(EdgeIt e(G); e!=INVALID; ++e) cap[e]=2*cap[e]; 
   102   preflow_test.setCap(cap);  
   103   preflow_test.setCap(cap);  
   103   preflow_test.setTarget(++t); //the max flow value remains 2*flow_value
   104 
       
   105   NodeIt tmp_node(G,t);
       
   106   ++tmp_node;
       
   107   t=tmp_node;
       
   108   
       
   109   preflow_test.setTarget(t); //the max flow value remains 2*flow_value
   104   //warning: ++t must be a valid node. In preflow_graph, it is.
   110   //warning: ++t must be a valid node. In preflow_graph, it is.
   105 
   111 
   106   preflow_test.phase1(PType::PRE_FLOW);
   112   preflow_test.phase1(PType::PRE_FLOW);
   107 
   113 
   108   CutMap mincut1(G,false);
   114   CutMap mincut1(G,false);