COIN-OR::LEMON - Graph Library

Changeset 372:e6a156fc186d in lemon-0.x for src/work/jacint/preflow.cc


Ignore:
Timestamp:
04/22/04 16:11:28 (17 years ago)
Author:
jacint
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@502
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/work/jacint/preflow.cc

    r220 r372  
    11#include <iostream>
    2 #include <fstream>
    32
    43#include <smart_graph.h>
    54#include <list_graph.h>
    65#include <dimacs.h>
    7 #include <preflow.h>
     6#include <preflowproba.h>
    87#include <time_measure.h>
    98
    109using namespace hugo;
    1110
    12 // Use a DIMACS max flow file as stdin.
    13 // read_dimacs_demo < dimacs_max_flow_file
    1411int main(int, char **) {
    15   typedef SmartGraph::Node Node;
    16   typedef SmartGraph::EdgeIt EdgeIt;
     12 
     13  typedef SmartGraph Graph;
     14 
     15  typedef Graph::Node Node;
     16  typedef Graph::EdgeIt EdgeIt;
    1717
    18   SmartGraph G;
     18  Graph G;
    1919  Node s, t;
    20   SmartGraph::EdgeMap<int> cap(G);
     20  Graph::EdgeMap<int> cap(G);
    2121  readDimacsMaxFlow(std::cin, G, s, t, cap);
    22 
     22  Timer ts;
     23 
    2324  std::cout << "preflow demo ..." << std::endl;
    2425 
    25   double mintime=1000000;
    26 
    27   for ( int i=1; i!=11; ++i ) {
    28     SmartGraph::EdgeMap<int> flow(G);
    29     double pre_time=currTime();
    30     Preflow<SmartGraph, int> max_flow_test(G, s, t, cap, flow);
    31     max_flow_test.run();
    32     double post_time=currTime();
    33     if ( mintime > post_time-pre_time ) mintime = post_time-pre_time;
    34   }
    35 
    36   SmartGraph::EdgeMap<int> flow(G);
    37   Preflow<SmartGraph, int> max_flow_test(G, s, t, cap, flow);
     26  Graph::EdgeMap<int> flow(G);
     27  Preflow<Graph, int> max_flow_test(G, s, t, cap, flow, 1);
     28  ts.reset();
    3829  max_flow_test.run();
     30  std::cout << "elapsed time: " << ts << std::endl;
    3931 
    40   SmartGraph::NodeMap<bool> cut(G);
     32  Graph::NodeMap<bool> cut(G);
    4133  max_flow_test.minCut(cut);
    4234  int min_cut_value=0;
     
    4638  }
    4739
    48   SmartGraph::NodeMap<bool> cut1(G);
     40  Graph::NodeMap<bool> cut1(G);
    4941  max_flow_test.minMinCut(cut1);
    5042  int min_min_cut_value=0;
     
    5446  }
    5547
    56   SmartGraph::NodeMap<bool> cut2(G);
     48  Graph::NodeMap<bool> cut2(G);
    5749  max_flow_test.maxMinCut(cut2);
    5850  int max_min_cut_value=0;
     
    6254      }
    6355 
    64   std::cout << "min time of 10 runs: " << mintime << " sec"<< std::endl;
    6556  std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
    6657  std::cout << "min cut value: "<< min_cut_value << std::endl;
Note: See TracChangeset for help on using the changeset viewer.