Demo prog that computes the max flow by LP
authoralpar
Fri, 08 Apr 2005 06:34:34 +0000
changeset 1322cfc26d103bcf
parent 1321 bc3a4c498eb2
child 1323 3aaadfb7de3d
Demo prog that computes the max flow by LP
src/demo/Makefile.am
src/demo/lp_demo.cc
     1.1 --- a/src/demo/Makefile.am	Fri Apr 08 06:33:11 2005 +0000
     1.2 +++ b/src/demo/Makefile.am	Fri Apr 08 06:34:34 2005 +0000
     1.3 @@ -1,16 +1,20 @@
     1.4  AM_CPPFLAGS = -I$(top_srcdir)/src
     1.5 -
     1.6 +LDADD = $(top_builddir)/src/lemon/libemon.la -lglpk
     1.7  EXTRA_DIST = sub_graph_wrapper_demo.dim
     1.8  
     1.9  noinst_PROGRAMS = 	dim_to_dot 					\
    1.10  			sub_graph_wrapper_demo 				\
    1.11  			graph_to_eps_demo 				\
    1.12 +			lp_demo                                         \
    1.13  			dim_to_lgf
    1.14  
    1.15  dim_to_dot_SOURCES = dim_to_dot.cc
    1.16  
    1.17 -sub_graph_wrapper_demo_SOURCES = sub_graph_wrapper_demo.cc tight_edge_filter_map.h
    1.18 +sub_graph_wrapper_demo_SOURCES = sub_graph_wrapper_demo.cc \
    1.19 +	tight_edge_filter_map.h
    1.20  
    1.21  graph_to_eps_demo_SOURCES = graph_to_eps_demo.cc
    1.22  
    1.23 +lp_demo_SOURCES = lp_demo.cc
    1.24 +
    1.25  dim_to_lgf_SOURCES = dim_to_lgf.cc
    1.26 \ No newline at end of file
     2.1 --- a/src/demo/lp_demo.cc	Fri Apr 08 06:33:11 2005 +0000
     2.2 +++ b/src/demo/lp_demo.cc	Fri Apr 08 06:34:34 2005 +0000
     2.3 @@ -37,10 +37,10 @@
     2.4      for(OutEdgeIt e(g,t);e!=INVALID;++e) ex-=x[e];
     2.5      lp.setObj(ex);
     2.6    }
     2.7 -
     2.8 +  lp.max();
     2.9    lp.solve();
    2.10  
    2.11 -  return 0;
    2.12 +  return lp.primalValue();
    2.13  }
    2.14  
    2.15  int main() 
    2.16 @@ -48,14 +48,19 @@
    2.17    LpGlpk lp_glpk;
    2.18  
    2.19    ListGraph g;
    2.20 -  ListGraph::Node s=g.addNode();
    2.21 -  ListGraph::Node t=g.addNode();
    2.22 +  ListGraph::Node s;
    2.23 +  ListGraph::Node t;
    2.24 +  
    2.25  
    2.26    ListGraph::EdgeMap<double> cap(g);
    2.27    
    2.28    GraphReader<ListGraph> reader(std::cin,g);
    2.29 -  reader.addEdgeMap("capacity",cap).run();
    2.30 +  reader.addNode("source",s).addNode("target",t)
    2.31 +    .addEdgeMap("capacity",cap).run();
    2.32    
    2.33 -  maxFlow(g,cap,s,t);
    2.34 +  // std::ifstream file("../test/preflow_");
    2.35 +//   readDimacs(file, g, cap, s, t);
    2.36 +
    2.37 +  std::cout << "Max flow value = " << maxFlow(g,cap,s,t) << std::endl;
    2.38  
    2.39  }