doc/getstart.dox
author athos
Fri, 24 Jun 2005 08:44:54 +0000
changeset 1511 d6b95a59da26
parent 1175 6205eebd62fc
child 1514 c9b9bc63db4e
permissions -rw-r--r--
Half-done, but I want to continue from home.
     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. If anything is not 
     7 clear write to our FAQ.
     8 
     9 \todo Is this FAQ thing a good idea here? Is there such a thing? If
    10 twice YES then a link comes here.
    11 
    12 
    13 
    14 \section downloadLEMON How to download LEMON
    15 
    16 You can download LEMON from the LEMON web site:
    17 http://lemon.cs.elte.hu
    18 by following the download link. There you will find the issued distributions in form of \e .ta.gz 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.
    19 
    20 
    21 \section installLEMON How to install LEMON
    22 
    23 In order to install LEMON you have to do the following
    24 
    25 Download the tarball and issue the following commands:
    26 
    27 \code
    28 tar xvzf lemon-0.3.1.tar.gz
    29 cd lemon-0.3.1
    30 ./configure
    31 make
    32 make check (This is optional, but recomended. It runs a bunch of tests.)
    33 make install
    34 \endcode
    35 
    36 These commands install LEMON under /usr/local. If you want to install it to some other place, then pass the --prefix=DIR flag to ./configure.
    37 
    38 Ide kell írni:
    39  
    40 -Hol fordul (Windows-os fordító nem fordítja, unix/linux alatt gcc hanyas verziója kell)
    41 -
    42 
    43 \section helloworld My first program using LEMON
    44 
    45 If you have installed LEMON on your system you can paste the following code
    46 segment into a file to have a first working program that uses library LEMON.
    47 
    48 \code
    49 #include <iostream>
    50 #include <lemon/list_graph.h>
    51 
    52 using namespace lemon;
    53 
    54 int main()
    55 {
    56   typedef ListGraph Graph;
    57   typedef Graph::Edge Edge;
    58   typedef Graph::InEdgeIt InEdgeIt;
    59   typedef Graph::OutEdgeIt OutEdgeIt;
    60   typedef Graph::EdgeIt EdgeIt;
    61   typedef Graph::Node Node;
    62   typedef Graph::NodeIt NodeIt;
    63 
    64   Graph g;
    65   
    66   for (int i = 0; i < 3; i++)
    67     g.addNode();
    68   
    69   for (NodeIt i(g); i!=INVALID; ++i)
    70     for (NodeIt j(g); j!=INVALID; ++j)
    71       if (i != j) g.addEdge(i, j);
    72 
    73   std::cout << "Nodes:";
    74   for (NodeIt i(g); i!=INVALID; ++i)
    75     std::cout << " " << g.id(i);
    76   std::cout << std::endl;
    77 
    78   std::cout << "Edges:";
    79   for (EdgeIt i(g); i!=INVALID; ++i)
    80     std::cout << " (" << g.id(g.source(i)) << "," << g.id(g.target(i)) << ")";
    81   std::cout << std::endl;
    82 
    83 \endcode
    84 
    85 
    86 ListGraph is one of LEMON's graph classes. It is based on linked lists,
    87 therefore iterating throuh its edges and nodes is fast.
    88 
    89 After some convenient typedefs we create a graph and add three nodes to it.
    90 Then we add edges to it to form a complete graph.
    91 
    92 Then we iterate through all nodes of the graph. We use a constructor of the
    93 node iterator to initialize it to the first node. The operator++ is used to
    94 step to the next node. Using operator++ on the iterator pointing to the last
    95 node invalidates the iterator i.e. sets its value to
    96 \ref lemon::INVALID "INVALID". This is what we exploit in the stop condition.
    97 
    98 We can also iterate through all edges of the graph very similarly. The 
    99 \c target and
   100 \c source member functions can be used to access the endpoints of an edge.
   101 
   102 The previous code fragment prints out the following:
   103 
   104 \code
   105 Nodes: 2 1 0
   106 
   107 Edges: (0,2) (1,2) (0,1) (2,1) (1,0) (2,0)
   108 \endcode
   109 
   110 
   111 If you want to see more features, go to the \ref quicktour "Quick Tour to
   112 LEMON", if you want to see see some demo programs then go to our 
   113 \ref demoprograms "Demo Programs" page! 
   114 
   115 
   116 */