Can you test more preflow algs?
authormarci
Mon, 16 Feb 2004 18:15:31 +0000
changeset 824d6a48fc0a2d
parent 81 6c8adcd6b482
child 83 efafe79a88d3
Can you test more preflow algs?
src/work/marci/comparison
src/work/marci/makefile
src/work/marci/preflow_demo_athos.cc
src/work/marci/preflow_demo_jacint.cc
     1.1 --- a/src/work/marci/comparison	Mon Feb 16 16:36:12 2004 +0000
     1.2 +++ b/src/work/marci/comparison	Mon Feb 16 18:15:31 2004 +0000
     1.3 @@ -1,4 +1,6 @@
     1.4 -./preflow_demo_leda < flow-1.dim
     1.5 -./preflow_demo_boost < flow-1.dim
     1.6 -./edmonds_karp_demo < flow-1.dim
     1.7 -./edmonds_karp_demo_boost < flow-1.dim
     1.8 \ No newline at end of file
     1.9 +./preflow_demo_leda < $1
    1.10 +./preflow_demo_boost < $1
    1.11 +./preflow_demo_jacint < $1
    1.12 +./preflow_demo_athos < $1
    1.13 +./edmonds_karp_demo < $1
    1.14 +./edmonds_karp_demo_boost < $1
     2.1 --- a/src/work/marci/makefile	Mon Feb 16 16:36:12 2004 +0000
     2.2 +++ b/src/work/marci/makefile	Mon Feb 16 18:15:31 2004 +0000
     2.3 @@ -3,7 +3,7 @@
     2.4  CXXFLAGS = -W -Wall -ansi -pedantic
     2.5  LEDAROOT = /ledasrc/LEDA-4.1
     2.6  
     2.7 -BINARIES = edmonds_karp_demo preflow_demo_leda preflow_demo_boost edmonds_karp_demo_boost
     2.8 +BINARIES = edmonds_karp_demo preflow_demo_leda preflow_demo_boost edmonds_karp_demo_boost preflow_demo_jacint preflow_demo_athos 
     2.9  
    2.10  all: $(BINARIES)
    2.11  
    2.12 @@ -27,6 +27,12 @@
    2.13  edmonds_karp_demo_boost:
    2.14  	$(CXX2) -ftemplate-depth-30 -O3 -I. -I/home/marci/boost -o edmonds_karp_demo_boost edmonds_karp_demo_boost.cc
    2.15  
    2.16 +preflow_demo_jacint: 
    2.17 +	$(CXX3) $(CXXFLAGS) -O3 -I. -I.. -I../jacint -o preflow_demo_jacint preflow_demo_jacint.cc
    2.18 +
    2.19 +preflow_demo_athos: 
    2.20 +	$(CXX3) $(CXXFLAGS) -O3 -I. -I.. -I../athos -o preflow_demo_athos preflow_demo_athos.cc
    2.21 +
    2.22  clean:
    2.23  	$(RM) *.o $(BINARIES) .depend
    2.24  
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/src/work/marci/preflow_demo_athos.cc	Mon Feb 16 18:15:31 2004 +0000
     3.3 @@ -0,0 +1,44 @@
     3.4 +#include <iostream>
     3.5 +#include <fstream>
     3.6 +
     3.7 +#include <list_graph.hh>
     3.8 +#include <dimacs.hh>
     3.9 +#include <preflow_push.hh>
    3.10 +#include <time_measure.h>
    3.11 +
    3.12 +using namespace marci;
    3.13 +
    3.14 +// Use a DIMACS max flow file as stdin.
    3.15 +// read_dimacs_demo < dimacs_max_flow_file
    3.16 +int main(int, char **) {
    3.17 +  typedef ListGraph::NodeIt NodeIt;
    3.18 +  typedef ListGraph::EachEdgeIt EachEdgeIt;
    3.19 +
    3.20 +  ListGraph G;
    3.21 +  NodeIt s, t;
    3.22 +  ListGraph::EdgeMap<int> cap(G);
    3.23 +  readDimacsMaxFlow(std::cin, G, s, t, cap);
    3.24 +
    3.25 +  std::cout << "preflow demo (ATHOS)..." << std::endl;
    3.26 +  //ListGraph::EdgeMap<int> flow(G); //0 flow
    3.27 +
    3.28 +  double pre_time=currTime();
    3.29 +  preflow_push<ListGraph, int> max_flow_test(G, s, t, cap);
    3.30 +  int flow_value=max_flow_test.run();
    3.31 +  //ListGraph::NodeMap<bool> cut=max_flow_test.mincut();
    3.32 +  //int cut_value=0;
    3.33 +  //for(EachEdgeIt e=G.first<EachEdgeIt>(); e.valid(); ++e) {
    3.34 +  //  if (cut.get(G.tail(e)) && !cut.get(G.head(e))) cut_value+=cap.get(e);
    3.35 +  //}
    3.36 +  double post_time=currTime();
    3.37 +  //std::cout << "maximum flow: "<< std::endl;
    3.38 +  //for(EachEdgeIt e=G.first<EachEdgeIt>(); e.valid(); ++e) { 
    3.39 +  //  std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
    3.40 +  //}
    3.41 +  //std::cout<<std::endl;
    3.42 +  std::cout << "elapsed time: " << post_time-pre_time << " sec"<< std::endl; 
    3.43 +  std::cout << "flow value: "<< flow_value << std::endl;
    3.44 +  //std::cout << "cut value: "<< cut_value << std::endl;
    3.45 +
    3.46 +  return 0;
    3.47 +}
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/src/work/marci/preflow_demo_jacint.cc	Mon Feb 16 18:15:31 2004 +0000
     4.3 @@ -0,0 +1,44 @@
     4.4 +#include <iostream>
     4.5 +#include <fstream>
     4.6 +
     4.7 +#include <list_graph.hh>
     4.8 +#include <dimacs.hh>
     4.9 +#include <preflow_push_max_flow.h>
    4.10 +#include <time_measure.h>
    4.11 +
    4.12 +using namespace marci;
    4.13 +
    4.14 +// Use a DIMACS max flow file as stdin.
    4.15 +// read_dimacs_demo < dimacs_max_flow_file
    4.16 +int main(int, char **) {
    4.17 +  typedef ListGraph::NodeIt NodeIt;
    4.18 +  typedef ListGraph::EachEdgeIt EachEdgeIt;
    4.19 +
    4.20 +  ListGraph G;
    4.21 +  NodeIt s, t;
    4.22 +  ListGraph::EdgeMap<int> cap(G);
    4.23 +  readDimacsMaxFlow(std::cin, G, s, t, cap);
    4.24 +
    4.25 +  std::cout << "preflow demo (JACINT)..." << std::endl;
    4.26 +  //ListGraph::EdgeMap<int> flow(G); //0 flow
    4.27 +
    4.28 +  double pre_time=currTime();
    4.29 +  preflow_push_max_flow<ListGraph, int> max_flow_test(G, s, t, cap);
    4.30 +  max_flow_test.run();
    4.31 +  ListGraph::NodeMap<bool> cut=max_flow_test.mincut();
    4.32 +  int cut_value=0;
    4.33 +  for(EachEdgeIt e=G.first<EachEdgeIt>(); e.valid(); ++e) {
    4.34 +    if (cut.get(G.tail(e)) && !cut.get(G.head(e))) cut_value+=cap.get(e);
    4.35 +  }
    4.36 +  double post_time=currTime();
    4.37 +  //std::cout << "maximum flow: "<< std::endl;
    4.38 +  //for(EachEdgeIt e=G.first<EachEdgeIt>(); e.valid(); ++e) { 
    4.39 +  //  std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
    4.40 +  //}
    4.41 +  //std::cout<<std::endl;
    4.42 +  std::cout << "elapsed time: " << post_time-pre_time << " sec"<< std::endl; 
    4.43 +  std::cout << "flow value: "<< max_flow_test.maxflow() << std::endl;
    4.44 +  std::cout << "cut value: "<< cut_value << std::endl;
    4.45 +
    4.46 +  return 0;
    4.47 +}