42 <ol> <li>The following code fragment shows how to fill a graph with |
42 <ol> <li>The following code fragment shows how to fill a graph with |
43 data. It creates a complete graph on 4 nodes. The type Listgraph is one of the |
43 data. It creates a complete graph on 4 nodes. The type Listgraph is one of the |
44 LEMON graph types: the typedefs in the beginning are for convenience and we |
44 LEMON graph types: the typedefs in the beginning are for convenience and we |
45 will suppose them later as well. |
45 will suppose them later as well. |
46 |
46 |
47 \code |
47 \dontinclude hello_lemon.cc |
48 |
48 \skip ListGraph |
49 typedef ListGraph Graph; |
49 \until addEdge |
50 typedef Graph::NodeIt NodeIt; |
50 |
51 |
51 See the whole program in file \ref hello_lemon.cc in \c demo subdir of |
52 Graph g; |
52 LEMON package. |
53 |
53 |
54 for (int i = 0; i < 3; i++) |
54 If you want to read more on the LEMON graph structures and |
55 g.addNode(); |
55 concepts, read the page about \ref graphs "graphs". |
56 |
56 |
57 for (NodeIt i(g); i!=INVALID; ++i) |
57 <li> The following code shows how to read a graph from a stream |
58 for (NodeIt j(g); j!=INVALID; ++j) |
58 (e.g. a file) in the DIMACS file format (find the documentation of the |
59 if (i != j) g.addEdge(i, j); |
59 DIMACS file formats on the web). |
60 |
|
61 \endcode |
|
62 |
|
63 See the whole program in file \ref helloworld.cc. |
|
64 |
|
65 If you want to read more on the LEMON graph structures and concepts, read the page about \ref graphs "graphs". |
|
66 |
|
67 <li> The following code shows how to read a graph from a stream (e.g. a file) |
|
68 in the DIMACS file format (find the documentation of the DIMACS file formats on the web). |
|
69 |
60 |
70 \code |
61 \code |
71 Graph g; |
62 Graph g; |
72 std::ifstream f("graph.dim"); |
63 std::ifstream f("graph.dim"); |
73 readDimacs(f, g); |
64 readDimacs(f, g); |
74 \endcode |
65 \endcode |
75 |
66 |
76 One can also store network (graph+capacity on the edges) instances and other |
67 One can also store network (graph+capacity on the edges) instances and |
77 things (minimum cost flow instances etc.) in DIMACS format and use these in LEMON: to see the details read the |
68 other things (minimum cost flow instances etc.) in DIMACS format and |
78 documentation of the \ref dimacs.h "Dimacs file format reader". There you will |
69 use these in LEMON: to see the details read the documentation of the |
79 also find the details about the output routines into files of the DIMACS |
70 \ref dimacs.h "Dimacs file format reader". There you will also find |
80 format. |
71 the details about the output routines into files of the DIMACS format. |
81 |
72 |
82 <li>We needed much greater flexibility than the DIMACS formats could give us, |
73 <li>DIMACS formats could not give us the flexibility we needed, |
83 so we worked out our own file format. Instead of any explanation let us give a |
74 so we worked out our own file format. Instead of any explanation let us give a |
84 short example file in this format: read the detailed description of the LEMON |
75 short example file in this format: read the detailed description of the LEMON |
85 graph file format and input-output routines \ref graph-io-page here. |
76 graph file format and input-output routines \ref graph-io-page here. |
86 |
77 |
87 So here is a file describing a graph of 10 nodes (0 to 9), two nodemaps |
78 So here is a file describing a graph of 10 nodes (0 to 9), two nodemaps |
237 usability for a customer and if it works well, but the performance |
228 usability for a customer and if it works well, but the performance |
238 should be improved, then one may decide to purchase and use a better |
229 should be improved, then one may decide to purchase and use a better |
239 commercial solver. |
230 commercial solver. |
240 |
231 |
241 So far we have an |
232 So far we have an |
242 interface for the commercial LP solver software \b CLPLEX (developed by ILOG) |
233 interface for the commercial LP solver software \b CPLEX (developed by ILOG) |
243 and for the open source solver \b GLPK (a shorthand for Gnu Linear Programming |
234 and for the open source solver \b GLPK (a shorthand for Gnu Linear Programming |
244 Toolkit). |
235 Toolkit). |
245 |
236 |
246 We will show two examples, the first one shows how simple it is to formalize |
237 We will show two examples, the first one shows how simple it is to formalize |
247 and solve an LP problem in LEMON, while the second one shows how LEMON |
238 and solve an LP problem in LEMON, while the second one shows how LEMON |