bug fix, test...
authormarci
Wed, 25 Aug 2004 18:55:57 +0000
changeset 773ce9438c5a82d
parent 772 f56eb959dd39
child 774 4297098d9677
bug fix, test...
src/hugo/max_flow.h
src/work/makefile
src/work/marci/bfsit_vs_byhand.cc
src/work/marci/graph_wrapper_time.cc
src/work/marci/makefile
     1.1 --- a/src/hugo/max_flow.h	Tue Aug 24 09:50:33 2004 +0000
     1.2 +++ b/src/hugo/max_flow.h	Wed Aug 25 18:55:57 2004 +0000
     1.3 @@ -838,7 +838,8 @@
     1.4  
     1.5  	    //putting the active nodes into the stack
     1.6  	    int lev=level[w];
     1.7 -	    if ( exc > 0 && lev < n && w != t ) 
     1.8 +	    if ( exc > 0 && lev < n && Node(w) != t ) 
     1.9 +///\bug	    if ( exc > 0 && lev < n && w != t ) tempararily for working with wrappers. in hugo 0.2 it will work. Amugy mukodik sage_graph-fal, de smart_graph-fal nem, azt hozzatennem.
    1.10  	      {
    1.11  		next.set(w,first[lev]);
    1.12  		first[lev]=w;
    1.13 @@ -855,7 +856,7 @@
    1.14  		 NNMap& right, int& b, int& k, bool what_heur )
    1.15      {
    1.16  
    1.17 -      Num lev=level[w];
    1.18 +      int lev=level[w];
    1.19  
    1.20        Node right_n=right[w];
    1.21        Node left_n=left[w];
     2.1 --- a/src/work/makefile	Tue Aug 24 09:50:33 2004 +0000
     2.2 +++ b/src/work/makefile	Wed Aug 25 18:55:57 2004 +0000
     2.3 @@ -1,5 +1,5 @@
     2.4  INCLUDEDIRS ?= -I.. -I. -I./{marci,jacint,alpar,klao,akos}
     2.5 -CXXFLAGS = -g -O2 -W -Wall $(INCLUDEDIRS) -ansi -pedantic
     2.6 +CXXFLAGS = -g -O3 -W -Wall $(INCLUDEDIRS) -ansi -pedantic
     2.7  
     2.8  BINARIES ?= bin_heap_demo
     2.9  
     3.1 --- a/src/work/marci/bfsit_vs_byhand.cc	Tue Aug 24 09:50:33 2004 +0000
     3.2 +++ b/src/work/marci/bfsit_vs_byhand.cc	Wed Aug 25 18:55:57 2004 +0000
     3.3 @@ -3,7 +3,7 @@
     3.4  #include <fstream>
     3.5  
     3.6  #include <sage_graph.h>
     3.7 -//#include <smart_graph.h>
     3.8 +#include <hugo/smart_graph.h>
     3.9  #include <hugo/dimacs.h>
    3.10  #include <hugo/time_measure.h>
    3.11  //#include <hugo/for_each_macros.h>
    3.12 @@ -11,6 +11,9 @@
    3.13  
    3.14  using namespace hugo;
    3.15  
    3.16 +using std::cout;
    3.17 +using std::endl;
    3.18 +
    3.19  int main() {
    3.20    typedef SageGraph Graph; 
    3.21    typedef Graph::Node Node;
    3.22 @@ -20,12 +23,18 @@
    3.23    typedef Graph::OutEdgeIt OutEdgeIt;
    3.24  
    3.25    Graph g;
    3.26 -  Node s, t;
    3.27 +  //Node s;
    3.28    //Graph::EdgeMap<int> cap(g);
    3.29    //readDimacsMaxFlow(std::cin, g, s, t, cap);
    3.30    readDimacs(std::cin, g);
    3.31 +  NodeIt s;
    3.32 +  g.first(s);
    3.33 +
    3.34 +  cout << g.nodeNum() << endl;
    3.35 +  cout << g.edgeNum() << endl;
    3.36  
    3.37    Graph::NodeMap<OutEdgeIt> pred(g);
    3.38 +  cout << "iteration time of bfs written by hand..." << endl;
    3.39    Timer ts;
    3.40    {
    3.41      ts.reset();
    3.42 @@ -33,7 +42,7 @@
    3.43      reached.set(s, true);
    3.44      pred.set(s, INVALID);
    3.45      std::queue<Node> bfs_queue;
    3.46 -    bfs_queue.push(t);
    3.47 +    bfs_queue.push(s);
    3.48      while (!bfs_queue.empty()) {
    3.49        Node v=bfs_queue.front();	
    3.50        bfs_queue.pop();
    3.51 @@ -51,6 +60,7 @@
    3.52      std::cout << ts << std::endl;
    3.53    }
    3.54  
    3.55 +  cout << "iteration time with bfs iterator..." << endl;
    3.56    {
    3.57      ts.reset();      
    3.58      BfsIterator< Graph, Graph::NodeMap<bool> > bfs(g);
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/src/work/marci/graph_wrapper_time.cc	Wed Aug 25 18:55:57 2004 +0000
     4.3 @@ -0,0 +1,76 @@
     4.4 +// -*- c++ -*-
     4.5 +
     4.6 +#include <iostream>
     4.7 +#include <fstream>
     4.8 +#include <string>
     4.9 +#include <vector>
    4.10 +#include <hugo/invalid.h>
    4.11 +#include <hugo/time_measure.h>
    4.12 +#include <hugo/graph_wrapper.h>
    4.13 +#include <hugo/max_flow.h>
    4.14 +#include <hugo/dimacs.h>
    4.15 +#include <hugo/list_graph.h>
    4.16 +
    4.17 +using namespace hugo;
    4.18 +
    4.19 +using std::cout;
    4.20 +using std::endl;
    4.21 +
    4.22 +template<typename Graph>
    4.23 +void timeTest(std::string str, Graph& g) {
    4.24 +  g.clear();
    4.25 +  typename Graph::Node s;
    4.26 +  typename Graph::Node t;
    4.27 +  typedef typename Graph::template EdgeMap<int> FlowMap;
    4.28 +  FlowMap cap(g);
    4.29 +  FlowMap flow(g);
    4.30 +  std::ifstream is(str.c_str());
    4.31 +  readDimacs(is, g, cap, s, t);
    4.32 +  Timer ts;
    4.33 +  ts.reset();
    4.34 +  cout << g.nodeNum() << endl;
    4.35 +  cout << g.edgeNum() << endl;
    4.36 +  typedef MaxFlow<Graph, int, FlowMap, FlowMap> MyMaxFlow;
    4.37 +  MyMaxFlow max_flow(g, s, t, cap, flow);
    4.38 +  max_flow.run(MyMaxFlow::NO_FLOW);
    4.39 +  cout << ts << endl;
    4.40 +}
    4.41 +
    4.42 +int main(int, char** argv) {
    4.43 +   std::string in=argv[1];
    4.44 +
    4.45 +  typedef ListGraph Graph; 
    4.46 +  Graph g;
    4.47 +//   cout << g.id(g.addNode()) << endl;
    4.48 +//   cout << g.id(g.addNode()) << endl;
    4.49 +//   cout << g.nodeNum() << endl;
    4.50 +  timeTest<Graph>(in, g);
    4.51 +  typedef GraphWrapper<Graph> Graph1;
    4.52 +  Graph1 g1(g);
    4.53 +//   g1.clear();
    4.54 +//   cout << g.id(g1.addNode()) << endl;
    4.55 +//   cout << g.id(g1.addNode()) << endl;
    4.56 +//   cout << g1.nodeNum() << endl;
    4.57 +//   g1.clear();
    4.58 +  timeTest<Graph1>(in, g1);
    4.59 +  typedef GraphWrapper<Graph1> Graph2;
    4.60 +  Graph2 g2(g1);
    4.61 +  timeTest<Graph2>(in, g2);
    4.62 +  typedef GraphWrapper<Graph2> Graph3;
    4.63 +  Graph3 g3(g2);
    4.64 +  timeTest<Graph3>(in, g3);
    4.65 +//   typedef GraphWrapper<Graph3> Graph4;
    4.66 +//   Graph4 g4(g3);
    4.67 +//   timeTest<Graph4>(in, g4);
    4.68 +//   typedef GraphWrapper<Graph4> Graph5;
    4.69 +//   Graph5 g5(g4);
    4.70 +//   timeTest<Graph5>(in, g5);
    4.71 +//   typedef GraphWrapper<Graph5> Graph6;
    4.72 +//   Graph6 g6(g5);
    4.73 +//   timeTest<Graph6>(in, g6);  
    4.74 +//   typedef GraphWrapper<Graph6> Graph7;
    4.75 +//   Graph7 g7(g6);
    4.76 +//   timeTest<Graph7>(in, g7);
    4.77 +
    4.78 +  return 0;
    4.79 +}
     5.1 --- a/src/work/marci/makefile	Tue Aug 24 09:50:33 2004 +0000
     5.2 +++ b/src/work/marci/makefile	Wed Aug 25 18:55:57 2004 +0000
     5.3 @@ -4,7 +4,7 @@
     5.4  INCLUDEDIRS ?= -I../{jacint,marci,alpar,klao,akos,athos} -I../.. -I.. -I$(BOOSTROOT)
     5.5  
     5.6  LEDABINARIES = leda_graph_demo leda_bfs_dfs max_bipartite_matching_demo
     5.7 -BINARIES = max_flow_demo iterator_bfs_demo macro_test lg_vs_sg_vs_sg bfsit_vs_byhand bipartite_graph_wrapper_test bipartite_matching_demo top_sort_test max_flow_1
     5.8 +BINARIES = graph_wrapper_time max_flow_demo iterator_bfs_demo macro_test lg_vs_sg_vs_sg bfsit_vs_byhand bipartite_graph_wrapper_test bipartite_matching_demo top_sort_test max_flow_1 proba7
     5.9  #BINARIES = preflow_bug
    5.10  #gw_vs_not preflow_demo_boost edmonds_karp_demo_boost preflow_demo_jacint preflow_demo_athos edmonds_karp_demo_alpar preflow_demo_leda
    5.11