[Lemon-commits] [lemon_svn] alpar: r1761 - hugo/trunk/src/demo
Lemon SVN
svn at lemon.cs.elte.hu
Mon Nov 6 20:47:23 CET 2006
Author: alpar
Date: Fri Apr 8 08:34:34 2005
New Revision: 1761
Modified:
hugo/trunk/src/demo/Makefile.am
hugo/trunk/src/demo/lp_demo.cc
Log:
Demo prog that computes the max flow by LP
Modified: hugo/trunk/src/demo/Makefile.am
==============================================================================
--- hugo/trunk/src/demo/Makefile.am (original)
+++ hugo/trunk/src/demo/Makefile.am Fri Apr 8 08:34:34 2005
@@ -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
Modified: hugo/trunk/src/demo/lp_demo.cc
==============================================================================
--- hugo/trunk/src/demo/lp_demo.cc (original)
+++ hugo/trunk/src/demo/lp_demo.cc Fri Apr 8 08:34:34 2005
@@ -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<double> cap(g);
GraphReader<ListGraph> 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;
}
More information about the Lemon-commits
mailing list