preflow mods
authormarci
Thu, 22 Apr 2004 16:07:17 +0000
changeset 3765c12f3515452
parent 375 d9a58896ab43
child 377 33fe0ee01dc5
preflow mods
src/work/jacint/preflowproba.h
src/work/marci/edmonds_karp_demo.cc
src/work/marci/graph_wrapper.h
src/work/marci/makefile
     1.1 --- a/src/work/jacint/preflowproba.h	Thu Apr 22 15:58:08 2004 +0000
     1.2 +++ b/src/work/jacint/preflowproba.h	Thu Apr 22 16:07:17 2004 +0000
     1.3 @@ -40,8 +40,8 @@
     1.4  
     1.5  */
     1.6  
     1.7 -#ifndef HUGO_PREFLOW_H
     1.8 -#define HUGO_PREFLOW_H
     1.9 +#ifndef HUGO_PREFLOW_PROBA_H
    1.10 +#define HUGO_PREFLOW_PROBA_H
    1.11  
    1.12  #define H0 20
    1.13  #define H1 1
    1.14 @@ -55,7 +55,7 @@
    1.15    template <typename Graph, typename T, 
    1.16  	    typename CapMap=typename Graph::EdgeMap<T>, 
    1.17              typename FlowMap=typename Graph::EdgeMap<T> >
    1.18 -  class Preflow {
    1.19 +  class PreflowProba {
    1.20      
    1.21      typedef typename Graph::Node Node;
    1.22      typedef typename Graph::Edge Edge;
    1.23 @@ -78,7 +78,7 @@
    1.24      typedef typename ResGW::Edge ResEdge;
    1.25   
    1.26    public:
    1.27 -    Preflow(Graph& _G, Node _s, Node _t, CapMap& _capacity, 
    1.28 +    PreflowProba(Graph& _G, Node _s, Node _t, CapMap& _capacity, 
    1.29  	    FlowMap& _flow, bool _constzero, bool _res ) :
    1.30        G(_G), s(_s), t(_t), capacity(_capacity), flow(_flow), constzero(_constzero), res(_res) {}
    1.31      
    1.32 @@ -682,7 +682,7 @@
    1.33  
    1.34  } //namespace hugo
    1.35  
    1.36 -#endif //PREFLOW_H
    1.37 +#endif //PREFLOW_PROBA_H
    1.38  
    1.39  
    1.40  
     2.1 --- a/src/work/marci/edmonds_karp_demo.cc	Thu Apr 22 15:58:08 2004 +0000
     2.2 +++ b/src/work/marci/edmonds_karp_demo.cc	Thu Apr 22 16:07:17 2004 +0000
     2.3 @@ -9,6 +9,7 @@
     2.4  #include <time_measure.h>
     2.5  //#include <graph_wrapper.h>
     2.6  #include <preflow.h>
     2.7 +#include <preflowproba.h>
     2.8  #include <for_each_macros.h>
     2.9  
    2.10  using namespace hugo;
    2.11 @@ -70,7 +71,9 @@
    2.12    Timer ts;
    2.13    Graph::EdgeMap<int> flow(G); //0 flow
    2.14    Preflow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> > 
    2.15 -    pre_flow_test(G, s, t, cap, flow);
    2.16 +    pre_flow_test(G, s, t, cap, flow, true);
    2.17 +  PreflowProba<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> > 
    2.18 +    pre_flow_proba(G, s, t, cap, flow, true, true);
    2.19    MaxFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> > 
    2.20      max_flow_test(G, s, t, cap, flow);
    2.21  
    2.22 @@ -83,6 +86,15 @@
    2.23    }
    2.24  
    2.25    {
    2.26 +    std::cout << "wrapped preflow ..." << std::endl;
    2.27 +    FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0);
    2.28 +    ts.reset();
    2.29 +    pre_flow_proba.run();
    2.30 +    std::cout << "elapsed time: " << ts << std::endl;
    2.31 +    std::cout << "flow value: "<< pre_flow_test.flowValue() << std::endl;
    2.32 +  }
    2.33 +
    2.34 +  {
    2.35      std::cout << "physical blocking flow augmentation ..." << std::endl;
    2.36      FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0);
    2.37      ts.reset();
     3.1 --- a/src/work/marci/graph_wrapper.h	Thu Apr 22 15:58:08 2004 +0000
     3.2 +++ b/src/work/marci/graph_wrapper.h	Thu Apr 22 16:07:17 2004 +0000
     3.3 @@ -696,6 +696,11 @@
     3.4      Node bNode(OutEdgeIt e) const { 
     3.5        return ((e.forward) ? graph->bNode(e.out) : graph->bNode(e.in)); }
     3.6  
     3.7 +    Node aNode(InEdgeIt e) const { 
     3.8 +      return ((e.forward) ? graph->aNode(e.in) : graph->aNode(e.out)); }
     3.9 +    Node bNode(InEdgeIt e) const { 
    3.10 +      return ((e.forward) ? graph->bNode(e.in) : graph->bNode(e.out)); }
    3.11 +
    3.12  //    int nodeNum() const { return graph->nodeNum(); }
    3.13      //FIXME
    3.14      void edgeNum() const { }
     4.1 --- a/src/work/marci/makefile	Thu Apr 22 15:58:08 2004 +0000
     4.2 +++ b/src/work/marci/makefile	Thu Apr 22 16:07:17 2004 +0000
     4.3 @@ -6,7 +6,7 @@
     4.4  BOOSTROOT ?= /home/marci/boost
     4.5  INCLUDEDIRS ?= -I../../include -I.. -I../{marci,jacint,alpar,klao,akos,athos} -I$(BOOSTROOT)
     4.6  LEDAINCLUDE ?= -I$(LEDAROOT)/incl
     4.7 -CXXFLAGS = -g -O -W -Wall $(INCLUDEDIRS) -ansi -pedantic -ftemplate-depth-30
     4.8 +CXXFLAGS = -g -O3 -W -Wall $(INCLUDEDIRS) -ansi -pedantic -ftemplate-depth-30
     4.9  
    4.10  LEDABINARIES = leda_graph_demo leda_bfs_dfs max_bipartite_matching_demo
    4.11  BINARIES = edmonds_karp_demo iterator_bfs_demo macro_test lg_vs_sg bfsit_vs_byhand bipartite_graph_wrapper_test
    4.12 @@ -41,8 +41,8 @@
    4.13  leda_bfs_dfs: leda_bfs_dfs.o
    4.14  	$(CXX3) -Wall -O -L$(LEDAROOT) -o leda_bfs_dfs leda_bfs_dfs.o -lG -lL -lm
    4.15  
    4.16 -edmonds_karp_demo: 
    4.17 -	$(CXX3) $(CXXFLAGS) -o edmonds_karp_demo edmonds_karp_demo.cc
    4.18 +#edmonds_karp_demo: 
    4.19 +#	$(CXX3) $(CXXFLAGS) -o edmonds_karp_demo edmonds_karp_demo.cc
    4.20  #	$(CXX3) $(CXXFLAGS) -pg -o edmonds_karp_demo_prof edmonds_karp_demo.cc
    4.21  
    4.22  gw_vs_not: