COIN-OR::LEMON - Graph Library

source: lemon-0.x/doc/getstart.dox @ 1528:1aa71600000c

Last change on this file since 1528:1aa71600000c was 1528:1aa71600000c, checked in by athos, 15 years ago

Graph input-output demo, some documentation.

File size: 5.5 KB
2\page getstart How to start using LEMON
[1519]4In this page we detail how to start using LEMON, from downloading it to
5your computer, through the steps of installation, to showing a simple
6"Hello World" type program that already uses LEMON. We assume that you
7have a basic knowledge of your operating system and \c C++ programming
8language. The procedure is pretty straightforward, but if you have any
9difficulties don't hesitate to
10<a href="">ask</a>.
[1514]12\section requirementsLEMON Hardware and software requirements
[1519]14In LEMON we use C++ templates heavily, thus compilation takes a
15considerable amount of time and memory. So some decent box would be
16advantageous. But otherwise there are no special hardware requirements.
[1519]18You will need a recent C++ compiler. Our primary target is the GNU C++
19Compiler (g++), from version 3.3 upwards. We also checked the Intel C
20compiler (icc). Microsoft Visual C++ .NET version was also reported to
21work (but not the earlier versions). If you want to develop with LEMON
22under Windows you could consider using Cygwin.
[1519]25In this description we will suppose a linux environment and GNU C Compiler.
[1173]27\section downloadLEMON How to download LEMON
[1511]29You can download LEMON from the LEMON web site:
[1519]31There you will find released versions in form of <tt>.tar.gz</tt> files.
32If you want a developer version (for example you want to contribute in
33developing the library LEMON) then you might want to use our Subversion
34repository. This case is not detailed here, so from now on we suppose that
35you downloaded a tar.gz file.
39\section installLEMON How to install LEMON
[1528]41In order to install LEMON you have to do the following steps.
[1519]43Download the tarball (named <tt>lemon-x.y.z.tar.gz</tt> where \c x,\c y
44and \c z are numbers indicating the version of the library: in our example
45we will have <tt>lemon-0.3.1.tar.gz</tt>) and issue the following
[1511]49tar xvzf lemon-0.3.1.tar.gz
50cd lemon-0.3.1
[1528]53make check   #(This is optional, but recommended. It runs a bunch of tests.)
[1511]54make install
[1519]57These commands install LEMON under \c /usr/local (you will
58need root privileges to be able to install to that
59directory). If you want to install it to some other place, then
[1528]60pass the \c --prefix=DIRECTORY flag to \c ./configure, for example:
63./configure --prefix=/home/user1/lemon
66In what follows we will assume that you were able to install to directory
[1519]67\c /usr/local, otherwise some extra care is to be taken to use the
[1514]70We briefly explain these commands below.
[1514]73tar xvzf lemon-0.3.1.tar.gz
75This command untars the <tt>tar.gz</tt> file into a directory named <tt>
[1514]79cd lemon-0.3.1
[1514]81Enters the directory.
[1514]86Does some configuration (creates makefiles etc).
[1519]87\todo Explain the most important switches here (gui, doc, glpk, cplex).
92This command compiles the non-template part of LEMON into
93<b>libemon.a</b> file. It also compiles some benchmark and demo
97make check
99This is an optional step: it runs the test programs that we
100developed for LEMON to check whether the library works properly on
101your platform.
[1514]104make install
[1514]106This will copy the directory structure to its final destination (e.g. to \c
[1519]107/usr/local) so that your system can access it. This command should
108be issued as "root", unless you provided a \c --prefix switch to
109the \c cofugure to install the library in non-default location.
[1173]111\section helloworld My first program using LEMON
[1519]113If you have installed LEMON on your system you can paste the
[1520]114following code segment into a file (you can find it as \c
115demo/ in the LEMON package) to have a first working
116program that uses library LEMON.
[1514]120First let us briefly explain how this program works.
122ListGraph is one of LEMON's graph classes. It is based on linked lists,
123therefore iterating throuh its edges and nodes is fast.
125After some convenient typedefs we create a graph and add three nodes to it.
126Then we add edges to it to form a complete graph.
128Then we iterate through all nodes of the graph. We use a constructor of the
129node iterator to initialize it to the first node. The operator++ is used to
130step to the next node. Using operator++ on the iterator pointing to the last
131node invalidates the iterator i.e. sets its value to
132\ref lemon::INVALID "INVALID". This is what we exploit in the stop condition.
134We can also iterate through all edges of the graph very similarly. The
135\c target and
136\c source member functions can be used to access the endpoints of an edge.
[1520]138If your installation of LEMON into directory \c /usr/local was
139successful then it is very easy to compile this program with the
140following command (the argument <tt>-lemon</tt> tells the compiler
141that we are using the installed library LEMON):
144g++ -o hello_lemon -lemon
147As a result you will get the exacutable \c hello_lemon in
[1514]148this directory that you can run by the command
[1519]154If everything has gone well then the previous code fragment prints
155out the following:
[1175]158Nodes: 2 1 0
160Edges: (0,2) (1,2) (0,1) (2,1) (1,0) (2,0)
[1519]165If you want to see more features, go to the
166\ref quicktour "Quick Tour to LEMON",
167if you want to see see some demo programs then go to our
[1175]168\ref demoprograms "Demo Programs" page!
Note: See TracBrowser for help on using the repository browser.