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