[Lemon-commits] [lemon_svn] athos: r2078 - hugo/trunk/demo
Lemon SVN
svn at lemon.cs.elte.hu
Mon Nov 6 20:49:58 CET 2006
Author: athos
Date: Wed Jul 20 18:05:04 2005
New Revision: 2078
Added:
hugo/trunk/demo/sub_gad_input.lgf
Modified:
hugo/trunk/demo/coloring.cc
hugo/trunk/demo/dim_to_dot.cc
hugo/trunk/demo/lp_demo.cc
hugo/trunk/demo/lp_maxflow_demo.cc
hugo/trunk/demo/sub_graph_adaptor_demo.cc
Log:
Documentation (lp_demo,lp_maxflow) and slight changes (rest).
Modified: hugo/trunk/demo/coloring.cc
==============================================================================
--- hugo/trunk/demo/coloring.cc (original)
+++ hugo/trunk/demo/coloring.cc Wed Jul 20 18:05:04 2005
@@ -16,7 +16,7 @@
{
if(argc<2)
{
- std::cerr << "USAGE: coloring <input_file.lgf>" << std::endl;
+ std::cerr << "USAGE: coloring input_file.lgf" << std::endl;
std::cerr << "The file 'input_file.lgf' has to contain a graph in LEMON format together with a nodemap called 'coords' to draw the graph (e.g. sample.lgf is not such a file)." << std::endl;
return 0;
}
Modified: hugo/trunk/demo/dim_to_dot.cc
==============================================================================
--- hugo/trunk/demo/dim_to_dot.cc (original)
+++ hugo/trunk/demo/dim_to_dot.cc Wed Jul 20 18:05:04 2005
@@ -6,6 +6,16 @@
// This program can be an aid in making up to date visualized documantation
// of demo programs.
+// For later documentation (if marci does not do it)
+// Az a graphviz csomag egy egyszeru formatuma, ami egy graphrajzolo csomag.
+// Az EdgeSubGraphAdaptor doksijaban szerepel egy kirajzolt graf. Azt nem
+// kezzel csinaltam, hanem a megfelelo dim file-bol ezzel a progival. A
+// doxygen ugyanis ilyet eszik, igy a juzer vizualisan is latja a grafot a
+// doksiban, es sajat maga is le tudja futtatni az algoritmust, mert ott van
+// a kezeben a dim file is. Es mivel ez egy generalt file, ezert ha vmit
+// valtoztatunk a dim-en, ezt is konnyu bemasolni. Uff.
+
+
#include <iostream>
#include <fstream>
@@ -17,8 +27,19 @@
using std::cout;
using std::endl;
-int main()
-{
+int main(int argc, char *argv[])
+{
+ if(argc<2)
+ {
+ std::cerr << "USAGE: sub_graph_adaptor_demo input_file.dim" << std::endl;
+ std::cerr << "The file 'input_file.dim' has to contain a max flow instance in DIMACS format (e.g. sub_graph_adaptor_demo.dim is such a file)." << std::endl;
+ return 0;
+ }
+
+
+ //input stream to read the graph from
+ std::ifstream is(argv[1]);
+
typedef SmartGraph Graph;
typedef Graph::Edge Edge;
@@ -31,7 +52,7 @@
Node s, t;
LengthMap length(g);
- readDimacs(std::cin, g, length, s, t);
+ readDimacs(is, g, length, s, t);
cout << "digraph lemon_dot_example {" << endl;
cout << " node [ shape=ellipse, fontname=Helvetica, fontsize=10 ];" << endl;
Modified: hugo/trunk/demo/lp_demo.cc
==============================================================================
--- hugo/trunk/demo/lp_demo.cc (original)
+++ hugo/trunk/demo/lp_demo.cc Wed Jul 20 18:05:04 2005
@@ -1,3 +1,29 @@
+/* -*- C++ -*-
+ * demo/graph_to_eps.cc - Part of LEMON, a generic C++ optimization library
+ *
+ * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
+ * (Egervary Research Group on Combinatorial Optimization, EGRES).
+ *
+ * Permission to use, modify and distribute this software is granted
+ * provided that this copyright notice appears in all copies. For
+ * precise terms see the accompanying LICENSE file.
+ *
+ * This software is provided "AS IS" with no warranty of any kind,
+ * express or implied, and with no claim as to its suitability for any
+ * purpose.
+ *
+ */
+
+/// \ingroup demos
+/// \file
+/// \brief A program demonstrating the LEMON LP solver interface
+///
+/// This program is a simple application of the LEMON LP solver
+/// interface: we formulate a linear programming (LP) problem and then
+/// solve it using the underlying solver (GLPK or CPLEX for
+/// example). For the detailed documentation of the LEMON LP solver
+/// interface read \ref lemon::LpSolverBase "this".
+
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@@ -13,10 +39,14 @@
using namespace lemon;
+
+
#ifdef HAVE_GLPK
typedef LpGlpk LpDefault;
+const char default_solver_name[]="GLPK";
#elif HAVE_CPLEX
typedef LpCplex LpDefault;
+const char default_solver_name[]="CPLEX";
#endif
int main()
@@ -30,6 +60,9 @@
typedef LpDefault::Col Col;
+ std::cout<<"A program demonstrating the LEMON LP solver interface"<<std::endl;
+ std::cout<<"Solver used: "<<default_solver_name<<std::endl;
+
//This will be a maximization
lp.max();
@@ -54,7 +87,8 @@
//Print results
if (lp.primalStatus()==LpSolverBase::OPTIMAL){
- printf("Z = %g; x1 = %g; x2 = %g; x3 = %g\n",
+ std::cout<<"Optimal solution found!"<<std::endl;
+ printf("optimum value = %g; x1 = %g; x2 = %g; x3 = %g\n",
lp.primalValue(),
lp.primal(x1), lp.primal(x2), lp.primal(x3));
}
Modified: hugo/trunk/demo/lp_maxflow_demo.cc
==============================================================================
--- hugo/trunk/demo/lp_maxflow_demo.cc (original)
+++ hugo/trunk/demo/lp_maxflow_demo.cc Wed Jul 20 18:05:04 2005
@@ -44,8 +44,10 @@
#ifdef HAVE_GLPK
typedef LpGlpk LpDefault;
+const char default_solver_name[]="GLPK";
#elif HAVE_CPLEX
typedef LpCplex LpDefault;
+const char default_solver_name[]="CPLEX";
#endif
@@ -96,6 +98,8 @@
lp.messageLevel(3);
#endif
+ std::cout<<"Solver used: "<<default_solver_name<<std::endl;
+
//Solve with the underlying solver
lp.solve();
@@ -106,7 +110,7 @@
{
if(argc<2)
{
- std::cerr << " USAGE: lp_maxflow_demo <input_file.lgf>" << std::endl;
+ std::cerr << " USAGE: lp_maxflow_demo input_file.lgf" << std::endl;
std::cerr << " The file 'input_file.lgf' has to contain a max "
<< "flow instance in\n"
<< " LEMON format (e.g. sample.lgf is such a file)."
Added: hugo/trunk/demo/sub_gad_input.lgf
==============================================================================
--- (empty file)
+++ hugo/trunk/demo/sub_gad_input.lgf Wed Jul 20 18:05:04 2005
@@ -0,0 +1,27 @@
+ at nodeset
+id
+6
+5
+4
+3
+2
+1
+0
+ at edgeset
+ id length
+5 6 9 4
+4 6 8 2
+3 5 7 1
+2 5 6 3
+2 6 5 5
+2 4 4 2
+1 4 3 3
+0 3 2 1
+0 2 1 2
+0 1 0 3
+ at nodes
+source 0
+target 6
+ at edges
+ at attributes
+ at end
Modified: hugo/trunk/demo/sub_graph_adaptor_demo.cc
==============================================================================
--- hugo/trunk/demo/sub_graph_adaptor_demo.cc (original)
+++ hugo/trunk/demo/sub_graph_adaptor_demo.cc Wed Jul 20 18:05:04 2005
@@ -16,6 +16,11 @@
#include <lemon/preflow.h>
#include <tight_edge_filter_map.h>
+
+
+//#include <lemon/graph_reader.h>
+//#include <lemon/graph_writer.h>
+
using namespace lemon;
using std::cout;
@@ -25,7 +30,7 @@
{
if(argc<2)
{
- std::cerr << "USAGE: sub_graph_adaptor_demo <input_file.dim>" << std::endl;
+ std::cerr << "USAGE: sub_graph_adaptor_demo input_file.dim" << std::endl;
std::cerr << "The file 'input_file.dim' has to contain a max flow instance in DIMACS format (e.g. sub_graph_adaptor_demo.dim is such a file)." << std::endl;
return 0;
}
@@ -48,6 +53,16 @@
readDimacs(is, g, length, s, t);
+// GraphWriter<SmartGraph> writer(std::cout, g);
+// writer.writeEdgeMap("length", length);
+// writer.writeNode("source",s);
+// writer.writeNode("target",t);
+// writer.run();
+
+// GraphReader<ListGraph> reader(is,g);
+// reader.readNode("source",s).readNode("target",t)
+// .readEdgeMap("length",length).run();
+
cout << "edges with lengths (of form id, source--length->target): " << endl;
for(EdgeIt e(g); e!=INVALID; ++e)
cout << " " << g.id(e) << ", " << g.id(g.source(e)) << "--"
More information about the Lemon-commits
mailing list