Some demo programs got some interface. Most progress with lp_maxflow_demo.cc, which also got documented.
1.1 --- a/demo/coloring.cc Fri Jul 15 14:35:07 2005 +0000
1.2 +++ b/demo/coloring.cc Fri Jul 15 16:01:55 2005 +0000
1.3 @@ -5,10 +5,26 @@
1.4 #include <lemon/graph_reader.h>
1.5 #include <lemon/graph_to_eps.h>
1.6
1.7 +#include <fstream>
1.8 +#include <iostream>
1.9 +
1.10 +
1.11 using namespace std;
1.12 using namespace lemon;
1.13
1.14 -int main() {
1.15 +int main(int argc, char *argv[])
1.16 +{
1.17 + if(argc<2)
1.18 + {
1.19 + std::cerr << "USAGE: coloring <input_file.lgf>" << std::endl;
1.20 + 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;
1.21 + return 0;
1.22 + }
1.23 +
1.24 +
1.25 + //input stream to read the graph from
1.26 + std::ifstream is(argv[1]);
1.27 +
1.28 typedef UndirSmartGraph Graph;
1.29 typedef Graph::Node Node;
1.30 typedef Graph::NodeIt NodeIt;
1.31 @@ -17,7 +33,7 @@
1.32
1.33 Graph graph;
1.34
1.35 - UndirGraphReader<Graph> reader(std::cin, graph);
1.36 + UndirGraphReader<Graph> reader(is, graph);
1.37 Graph::NodeMap<xy<double> > coords(graph);
1.38 reader.readNodeMap("coords", coords);
1.39
2.1 --- a/demo/lp_maxflow_demo.cc Fri Jul 15 14:35:07 2005 +0000
2.2 +++ b/demo/lp_maxflow_demo.cc Fri Jul 15 16:01:55 2005 +0000
2.3 @@ -1,3 +1,28 @@
2.4 +/* -*- C++ -*-
2.5 + * demo/lp_maxflow_demo.cc - Part of LEMON, a generic C++ optimization library
2.6 + *
2.7 + * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
2.8 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
2.9 + *
2.10 + * Permission to use, modify and distribute this software is granted
2.11 + * provided that this copyright notice appears in all copies. For
2.12 + * precise terms see the accompanying LICENSE file.
2.13 + *
2.14 + * This software is provided "AS IS" with no warranty of any kind,
2.15 + * express or implied, and with no claim as to its suitability for any
2.16 + * purpose.
2.17 + *
2.18 + */
2.19 +
2.20 +///\ingroup demos
2.21 +///\file
2.22 +///\brief Max flow problem solved with an LP solver (demo).
2.23 +///
2.24 +///This demo program shows how to solve a maximum (or maximal) flow
2.25 +///problem using the LEMON LP solver interface. We would like to lay
2.26 +///the emphasis on the simplicity of the way one can formulate the LP
2.27 +///constraints with LEMON that arise in graph theory.
2.28 +
2.29 #ifdef HAVE_CONFIG_H
2.30 #include <config.h>
2.31 #endif
2.32 @@ -5,6 +30,9 @@
2.33 #include<lemon/graph_reader.h>
2.34 #include<lemon/list_graph.h>
2.35
2.36 +#include <fstream>
2.37 +#include <iostream>
2.38 +
2.39
2.40 #ifdef HAVE_GLPK
2.41 #include <lemon/lp_glpk.h>
2.42 @@ -75,21 +103,30 @@
2.43 return lp.primalValue();
2.44 }
2.45
2.46 -int main()
2.47 +int main(int argc, char *argv[])
2.48 {
2.49 + if(argc<2)
2.50 + {
2.51 + std::cerr << "USAGE: lp_maxflow_demo <input_file.lgf>" << std::endl;
2.52 + std::cerr << "The file 'input_file.lgf' has to contain a max flow instance in LEMON format (e.g. sample.lgf is such a file)." << std::endl;
2.53 + return 0;
2.54 + }
2.55 +
2.56 +
2.57 + //input stream to read the graph from
2.58 + std::ifstream is(argv[1]);
2.59 +
2.60 +
2.61 ListGraph g;
2.62 ListGraph::Node s;
2.63 ListGraph::Node t;
2.64
2.65 ListGraph::EdgeMap<double> cap(g);
2.66
2.67 - GraphReader<ListGraph> reader(std::cin,g);
2.68 + GraphReader<ListGraph> reader(is,g);
2.69 reader.readNode("source",s).readNode("target",t)
2.70 .readEdgeMap("capacity",cap).run();
2.71
2.72 - // std::ifstream file("../test/preflow_");
2.73 -// readDimacs(file, g, cap, s, t);
2.74 -
2.75 std::cout << "Max flow value = " << maxFlow(g,cap,s,t) << std::endl;
2.76
2.77 }
3.1 --- a/demo/sub_graph_adaptor_demo.cc Fri Jul 15 14:35:07 2005 +0000
3.2 +++ b/demo/sub_graph_adaptor_demo.cc Fri Jul 15 16:01:55 2005 +0000
3.3 @@ -1,6 +1,6 @@
3.4 // -*- c++ -*-
3.5
3.6 -// Use a DIMACS max flow file as stdin.
3.7 +// Use a DIMACS max flow file as input.
3.8 // sub_graph_adaptor_demo < dimacs_max_flow_file
3.9 // This program computes a maximum number of edge-disjoint shortest paths
3.10 // between s and t.
3.11 @@ -21,8 +21,19 @@
3.12 using std::cout;
3.13 using std::endl;
3.14
3.15 -int main()
3.16 -{
3.17 +int main(int argc, char *argv[])
3.18 +{
3.19 + if(argc<2)
3.20 + {
3.21 + std::cerr << "USAGE: sub_graph_adaptor_demo <input_file.dim>" << std::endl;
3.22 + 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;
3.23 + return 0;
3.24 + }
3.25 +
3.26 +
3.27 + //input stream to read the graph from
3.28 + std::ifstream is(argv[1]);
3.29 +
3.30 typedef SmartGraph Graph;
3.31
3.32 typedef Graph::Edge Edge;
3.33 @@ -35,7 +46,7 @@
3.34 Node s, t;
3.35 LengthMap length(g);
3.36
3.37 - readDimacs(std::cin, g, length, s, t);
3.38 + readDimacs(is, g, length, s, t);
3.39
3.40 cout << "edges with lengths (of form id, source--length->target): " << endl;
3.41 for(EdgeIt e(g); e!=INVALID; ++e)