doc/getstart.dox
author alpar
Mon, 18 Apr 2005 14:59:24 +0000
changeset 1367 a490662291b9
parent 1173 099978eee03f
child 1511 d6b95a59da26
permissions -rw-r--r--
More steps toward gcc-3.4 compatibility
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@1175
    14
athos@1173
    15
\section downloadLEMON How to download LEMON
athos@1173
    16
athos@1175
    17
You can download LEMON from the following web site:
athos@1175
    18
athos@1173
    19
athos@1173
    20
\section installLEMON How to install LEMON
athos@1173
    21
athos@1173
    22
In order to install LEMON you have to do the following
athos@1173
    23
athos@1175
    24
Ide kell írni:
athos@1175
    25
 
athos@1175
    26
-Hol fordul (Windows-os fordító nem fordítja, unix/linux alatt gcc hanyas verziója kell)
athos@1175
    27
-
athos@1175
    28
athos@1173
    29
\section helloworld My first program using LEMON
athos@1173
    30
athos@1175
    31
If you have installed LEMON on your system you can paste the following code
athos@1175
    32
segment into a file to have a first working program that uses library LEMON.
athos@1173
    33
athos@1175
    34
\code
athos@1175
    35
#include <iostream>
athos@1175
    36
#include <lemon/list_graph.h>
athos@1173
    37
athos@1175
    38
using namespace lemon;
athos@1175
    39
athos@1175
    40
int main()
athos@1175
    41
{
athos@1175
    42
  typedef ListGraph Graph;
athos@1175
    43
  typedef Graph::Edge Edge;
athos@1175
    44
  typedef Graph::InEdgeIt InEdgeIt;
athos@1175
    45
  typedef Graph::OutEdgeIt OutEdgeIt;
athos@1175
    46
  typedef Graph::EdgeIt EdgeIt;
athos@1175
    47
  typedef Graph::Node Node;
athos@1175
    48
  typedef Graph::NodeIt NodeIt;
athos@1175
    49
athos@1175
    50
  Graph g;
athos@1175
    51
  
athos@1175
    52
  for (int i = 0; i < 3; i++)
athos@1175
    53
    g.addNode();
athos@1175
    54
  
athos@1175
    55
  for (NodeIt i(g); i!=INVALID; ++i)
athos@1175
    56
    for (NodeIt j(g); j!=INVALID; ++j)
athos@1175
    57
      if (i != j) g.addEdge(i, j);
athos@1175
    58
athos@1175
    59
  std::cout << "Nodes:";
athos@1175
    60
  for (NodeIt i(g); i!=INVALID; ++i)
athos@1175
    61
    std::cout << " " << g.id(i);
athos@1175
    62
  std::cout << std::endl;
athos@1175
    63
athos@1175
    64
  std::cout << "Edges:";
athos@1175
    65
  for (EdgeIt i(g); i!=INVALID; ++i)
athos@1175
    66
    std::cout << " (" << g.id(g.source(i)) << "," << g.id(g.target(i)) << ")";
athos@1175
    67
  std::cout << std::endl;
athos@1175
    68
athos@1175
    69
\endcode
athos@1175
    70
athos@1175
    71
athos@1175
    72
ListGraph is one of LEMON's graph classes. It is based on linked lists,
athos@1175
    73
therefore iterating throuh its edges and nodes is fast.
athos@1175
    74
athos@1175
    75
After some convenient typedefs we create a graph and add three nodes to it.
athos@1175
    76
Then we add edges to it to form a complete graph.
athos@1175
    77
athos@1175
    78
Then we iterate through all nodes of the graph. We use a constructor of the
athos@1175
    79
node iterator to initialize it to the first node. The operator++ is used to
athos@1175
    80
step to the next node. Using operator++ on the iterator pointing to the last
athos@1175
    81
node invalidates the iterator i.e. sets its value to
athos@1175
    82
\ref lemon::INVALID "INVALID". This is what we exploit in the stop condition.
athos@1175
    83
athos@1175
    84
We can also iterate through all edges of the graph very similarly. The 
athos@1175
    85
\c target and
athos@1175
    86
\c source member functions can be used to access the endpoints of an edge.
athos@1175
    87
athos@1175
    88
The previous code fragment prints out the following:
athos@1175
    89
athos@1175
    90
\code
athos@1175
    91
Nodes: 2 1 0
athos@1175
    92
athos@1175
    93
Edges: (0,2) (1,2) (0,1) (2,1) (1,0) (2,0)
athos@1175
    94
\endcode
athos@1175
    95
athos@1175
    96
athos@1175
    97
If you want to see more features, go to the \ref quicktour "Quick Tour to
athos@1175
    98
LEMON", if you want to see see some demo programs then go to our 
athos@1175
    99
\ref demoprograms "Demo Programs" page! 
athos@1175
   100
athos@1175
   101
athos@1175
   102
*/