# HG changeset patch # User alpar # Date 1112942074 0 # Node ID cfc26d103bcf73d7d2536bb7b226dc0254b4a0f4 # Parent bc3a4c498eb25147d0f5ef53947a2a3a1b57acc4 Demo prog that computes the max flow by LP diff -r bc3a4c498eb2 -r cfc26d103bcf src/demo/Makefile.am --- a/src/demo/Makefile.am Fri Apr 08 06:33:11 2005 +0000 +++ b/src/demo/Makefile.am Fri Apr 08 06:34:34 2005 +0000 @@ -1,16 +1,20 @@ AM_CPPFLAGS = -I$(top_srcdir)/src - +LDADD = $(top_builddir)/src/lemon/libemon.la -lglpk EXTRA_DIST = sub_graph_wrapper_demo.dim noinst_PROGRAMS = dim_to_dot \ sub_graph_wrapper_demo \ graph_to_eps_demo \ + lp_demo \ dim_to_lgf dim_to_dot_SOURCES = dim_to_dot.cc -sub_graph_wrapper_demo_SOURCES = sub_graph_wrapper_demo.cc tight_edge_filter_map.h +sub_graph_wrapper_demo_SOURCES = sub_graph_wrapper_demo.cc \ + tight_edge_filter_map.h graph_to_eps_demo_SOURCES = graph_to_eps_demo.cc +lp_demo_SOURCES = lp_demo.cc + dim_to_lgf_SOURCES = dim_to_lgf.cc \ No newline at end of file diff -r bc3a4c498eb2 -r cfc26d103bcf src/demo/lp_demo.cc --- a/src/demo/lp_demo.cc Fri Apr 08 06:33:11 2005 +0000 +++ b/src/demo/lp_demo.cc Fri Apr 08 06:34:34 2005 +0000 @@ -37,10 +37,10 @@ for(OutEdgeIt e(g,t);e!=INVALID;++e) ex-=x[e]; lp.setObj(ex); } - + lp.max(); lp.solve(); - return 0; + return lp.primalValue(); } int main() @@ -48,14 +48,19 @@ LpGlpk lp_glpk; ListGraph g; - ListGraph::Node s=g.addNode(); - ListGraph::Node t=g.addNode(); + ListGraph::Node s; + ListGraph::Node t; + ListGraph::EdgeMap cap(g); GraphReader reader(std::cin,g); - reader.addEdgeMap("capacity",cap).run(); + reader.addNode("source",s).addNode("target",t) + .addEdgeMap("capacity",cap).run(); - maxFlow(g,cap,s,t); + // std::ifstream file("../test/preflow_"); +// readDimacs(file, g, cap, s, t); + + std::cout << "Max flow value = " << maxFlow(g,cap,s,t) << std::endl; }