doc/getstart.dox
author athos
Mon, 27 Jun 2005 15:25:33 +0000
changeset 1518 f8efed98d6a3
parent 1514 c9b9bc63db4e
child 1519 17e367a93cbb
permissions -rw-r--r--
Only added comments.
     1 /**
     2 \page getstart How to start using LEMON
     3 
     4 In this page we detail how to start using LEMON, from downloading it to 
     5 your computer, through the steps of installation to showing a simple
     6 "Hello World" type program that already uses LEMON. We assume that you have a
     7 basic knowledge of your operating system and \c C++ or \c C 
     8 programming language. 
     9 
    10 \section requirementsLEMON Hardware and software requirements
    11 
    12 Hardware requirements ...
    13 
    14 You will also need a C++ compiler. We mostly used the Gnu C++ Compiler (g++),
    15 from version 3.0 upwards. We also checked the Intel C compiler
    16 (icc). Unfortunately, Visual C++ compiler knows not enough to compile the
    17 library, so if you are using Microsoft Windows, then try to compile under
    18 Cygwin. 
    19 
    20 Ide kell írni:
    21  
    22 -Hol fordul (Windows-os fordító nem fordítja, unix/linux alatt gcc hanyas verziója kell)
    23 -
    24 
    25 In this description we will suppose a linux environment and Gnu C Compiler.
    26 
    27 \section downloadLEMON How to download LEMON
    28 
    29 You can download LEMON from the LEMON web site:
    30 http://lemon.cs.elte.hu/dowload.html
    31 . There you will find the issued distributions
    32 in form of <tt> .tar.gz </tt> files. If you want a developer version  (for example you want to contribute in developing the library LEMON) then you might want to use our Subversion repository. This case is not detailed here, so from now on we suppose that you downloaded a tar.gz file.
    33 
    34 
    35 
    36 \section installLEMON How to install LEMON
    37 
    38 In order to install LEMON you have to do the following
    39 
    40 Download the tarball (named <tt>lemon-x.y.z.tar.gz</tt> where \c x,\c y and \c z are
    41 numbers indicating the version of the library: in our example we will have lemon-0.3.1) and issue the following commands:
    42 
    43 \code
    44 tar xvzf lemon-0.3.1.tar.gz
    45 cd lemon-0.3.1
    46 ./configure
    47 make
    48 make check (This is optional, but recomended. It runs a bunch of tests.)
    49 make install
    50 \endcode
    51 
    52 These commands install LEMON under \c /usr/local (you will probably need \c root
    53 privileges to be able to install to that directory). If you want to install it
    54 to some other place, then pass the \c --prefix=DIR flag to \c ./configure. In
    55 what follows we will assume that you were able to install to directory \c
    56 /usr/local, otherwise some extra care is to be taken to use the library.
    57 
    58 We briefly explain these commands below.
    59 
    60 \code
    61 tar xvzf lemon-0.3.1.tar.gz
    62 \endcode
    63 This command untars the <tt>tar.gz</tt> file into a directory named <tt> lemon-0.3.1</tt>.
    64 
    65 \code
    66 cd lemon-0.3.1
    67 \endcode
    68 Enters the directory.
    69 
    70 \code
    71 ./configure
    72 \endcode
    73 Does some configuration (creates makefiles etc).
    74 
    75 \code
    76 make
    77 \endcode
    78 This command compiles the <tt> .cc</tt> files of the library package (the
    79 implementation of non-template functions and classes and some test and demo
    80 programs) and creates the very important <b> libemon.la </b> file. When
    81 linking your program that uses LEMON it needs to access this file.
    82 
    83 \code
    84 make check (This is optional, but recomended. It runs a bunch of tests.)
    85 \endcode
    86 This is an optional step: it runs the test programs that we developed for
    87 LEMON to check
    88 whether the library works properly on your platform.
    89 
    90 \code
    91 make install
    92 \endcode
    93 This will copy the directory structure to its final destination (e.g. to \c
    94 /usr/local) so that your system can access it.
    95 
    96 \section helloworld My first program using LEMON
    97 
    98 If you have installed LEMON on your system you 
    99 can paste the following code
   100 segment into a file to have a first working program that uses library LEMON.
   101 
   102 \code
   103 #include <iostream>
   104 #include <lemon/list_graph.h>
   105 
   106 using namespace lemon;
   107 
   108 int main()
   109 {
   110   typedef ListGraph Graph;
   111   typedef Graph::EdgeIt EdgeIt;
   112   typedef Graph::NodeIt NodeIt;
   113 
   114   Graph g;
   115   
   116   for (int i = 0; i < 3; i++)
   117     g.addNode();
   118   
   119   for (NodeIt i(g); i!=INVALID; ++i)
   120     for (NodeIt j(g); j!=INVALID; ++j)
   121       if (i != j) g.addEdge(i, j);
   122 
   123   std::cout << "Nodes:";
   124   for (NodeIt i(g); i!=INVALID; ++i)
   125     std::cout << " " << g.id(i);
   126   std::cout << std::endl;
   127 
   128   std::cout << "Edges:";
   129   for (EdgeIt i(g); i!=INVALID; ++i)
   130     std::cout << " (" << g.id(g.source(i)) << "," << g.id(g.target(i)) << ")";
   131   std::cout << std::endl;
   132 
   133 \endcode
   134 
   135 First let us briefly explain how this program works.
   136 
   137 ListGraph is one of LEMON's graph classes. It is based on linked lists,
   138 therefore iterating throuh its edges and nodes is fast.
   139 
   140 After some convenient typedefs we create a graph and add three nodes to it.
   141 Then we add edges to it to form a complete graph.
   142 
   143 Then we iterate through all nodes of the graph. We use a constructor of the
   144 node iterator to initialize it to the first node. The operator++ is used to
   145 step to the next node. Using operator++ on the iterator pointing to the last
   146 node invalidates the iterator i.e. sets its value to
   147 \ref lemon::INVALID "INVALID". This is what we exploit in the stop condition.
   148 
   149 We can also iterate through all edges of the graph very similarly. The 
   150 \c target and
   151 \c source member functions can be used to access the endpoints of an edge.
   152 
   153 If you have saved the preceding code into a file named, say,  \c hemon.cc and your installation of LEMON into directory \c /usr/local was
   154 successful then it is very easy to compile this program with the following
   155 command (the argument <tt>-lemon</tt> tells the compiler that we are using the
   156 installed library LEMON):
   157 \code
   158 g++ hemon.cc -o hemon -lemon
   159 \endcode
   160 
   161 As a result you will get the exacutable \c hemon in
   162 this directory that you can run by the command 
   163 \code
   164 ./hemon
   165 \endcode
   166 
   167 
   168 If everything has gone well then the previous code fragment prints out the following:
   169 
   170 \code
   171 Nodes: 2 1 0
   172 
   173 Edges: (0,2) (1,2) (0,1) (2,1) (1,0) (2,0)
   174 \endcode
   175 
   176 Congratulations!
   177 
   178 If you want to see more features, go to the \ref quicktour "Quick Tour to
   179 LEMON", if you want to see see some demo programs then go to our 
   180 \ref demoprograms "Demo Programs" page! 
   181 
   182 
   183 */