COIN-OR::LEMON - Graph Library

Changeset 1175:6205eebd62fc in lemon-0.x for doc/getstart.dox


Ignore:
Timestamp:
02/24/05 18:04:49 (15 years ago)
Author:
athos
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1581
Message:

Everithing is half-done, but some progress has been made in writing documentation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/getstart.dox

    r1173 r1175  
    22\page getstart How to start using LEMON
    33
     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. If anything is not
     7clear write to our FAQ.
     8
     9\todo Is this FAQ thing a good idea here? Is there such a thing? If
     10twice YES then a link comes here.
     11
     12
     13
     14
    415\section downloadLEMON How to download LEMON
    516
    6 You can download LEMON from ...
     17You can download LEMON from the following web site:
     18
    719
    820\section installLEMON How to install LEMON
     
    1022In order to install LEMON you have to do the following
    1123
     24Ide kell írni:
     25 
     26-Hol fordul (Windows-os fordító nem fordítja, unix/linux alatt gcc hanyas verziója kell)
     27-
     28
    1229\section helloworld My first program using LEMON
    1330
    14 Helloworld program
    15 Link to quicktour
     31If you have installed LEMON on your system you can paste the following code
     32segment into a file to have a first working program that uses library LEMON.
     33
     34\code
     35#include <iostream>
     36#include <lemon/list_graph.h>
     37
     38using namespace lemon;
     39
     40int main()
     41{
     42  typedef ListGraph Graph;
     43  typedef Graph::Edge Edge;
     44  typedef Graph::InEdgeIt InEdgeIt;
     45  typedef Graph::OutEdgeIt OutEdgeIt;
     46  typedef Graph::EdgeIt EdgeIt;
     47  typedef Graph::Node Node;
     48  typedef Graph::NodeIt NodeIt;
     49
     50  Graph g;
     51 
     52  for (int i = 0; i < 3; i++)
     53    g.addNode();
     54 
     55  for (NodeIt i(g); i!=INVALID; ++i)
     56    for (NodeIt j(g); j!=INVALID; ++j)
     57      if (i != j) g.addEdge(i, j);
     58
     59  std::cout << "Nodes:";
     60  for (NodeIt i(g); i!=INVALID; ++i)
     61    std::cout << " " << g.id(i);
     62  std::cout << std::endl;
     63
     64  std::cout << "Edges:";
     65  for (EdgeIt i(g); i!=INVALID; ++i)
     66    std::cout << " (" << g.id(g.source(i)) << "," << g.id(g.target(i)) << ")";
     67  std::cout << std::endl;
     68
     69\endcode
     70
     71
     72ListGraph is one of LEMON's graph classes. It is based on linked lists,
     73therefore iterating throuh its edges and nodes is fast.
     74
     75After some convenient typedefs we create a graph and add three nodes to it.
     76Then we add edges to it to form a complete graph.
     77
     78Then we iterate through all nodes of the graph. We use a constructor of the
     79node iterator to initialize it to the first node. The operator++ is used to
     80step to the next node. Using operator++ on the iterator pointing to the last
     81node invalidates the iterator i.e. sets its value to
     82\ref lemon::INVALID "INVALID". This is what we exploit in the stop condition.
     83
     84We can also iterate through all edges of the graph very similarly. The
     85\c target and
     86\c source member functions can be used to access the endpoints of an edge.
     87
     88The previous code fragment prints out the following:
     89
     90\code
     91Nodes: 2 1 0
     92
     93Edges: (0,2) (1,2) (0,1) (2,1) (1,0) (2,0)
     94\endcode
     95
     96
     97If you want to see more features, go to the \ref quicktour "Quick Tour to
     98LEMON", if you want to see see some demo programs then go to our
     99\ref demoprograms "Demo Programs" page!
    16100
    17101
Note: See TracChangeset for help on using the changeset viewer.