athos@1173: /** athos@1173: \page getstart How to start using LEMON athos@1173: athos@1175: In this page we detail how to start using LEMON, from downloading it to athos@1175: your computer, through the steps of installation to showing a simple athos@1514: "Hello World" type program that already uses LEMON. We assume that you have a athos@1514: basic knowledge of your operating system and \c C++ or \c C athos@1514: programming language. If anything is not athos@1175: clear write to our FAQ. athos@1175: athos@1175: \todo Is this FAQ thing a good idea here? Is there such a thing? If athos@1175: twice YES then a link comes here. athos@1175: athos@1514: \section requirementsLEMON Hardware and software requirements athos@1175: athos@1514: Hardware requirements ... athos@1514: athos@1514: You will also need a C++ compiler. We mostly used the Gnu C++ Compiler (g++), athos@1514: from version 3.0 upwards. We also checked the Intel C compiler athos@1514: (icc). Unfortunately, Visual C++ compiler knows not enough to compile the athos@1514: library, so if you are using Microsoft Windows, then try to compile under athos@1514: Cygwin. athos@1514: athos@1514: Ide kell írni: athos@1514: athos@1514: -Hol fordul (Windows-os fordító nem fordítja, unix/linux alatt gcc hanyas verziója kell) athos@1514: - athos@1514: athos@1514: In this description we will suppose a linux environment and Gnu C Compiler. athos@1175: athos@1173: \section downloadLEMON How to download LEMON athos@1173: athos@1511: You can download LEMON from the LEMON web site: athos@1511: http://lemon.cs.elte.hu athos@1514: by following the download link. There you will find the issued distributions athos@1514: in form of .tar.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@1514: athos@1175: athos@1173: athos@1173: \section installLEMON How to install LEMON athos@1173: athos@1173: In order to install LEMON you have to do the following athos@1173: athos@1514: Download the tarball (named lemon-x.y.z.tar.gz where \c x,\c y and \c z are athos@1514: numbers indicating the version of the library: in our example we will have lemon-0.3.1) and issue the following commands: athos@1511: athos@1511: \code athos@1511: tar xvzf lemon-0.3.1.tar.gz athos@1511: cd lemon-0.3.1 athos@1511: ./configure athos@1511: make athos@1511: make check (This is optional, but recomended. It runs a bunch of tests.) athos@1511: make install athos@1511: \endcode athos@1511: athos@1514: These commands install LEMON under \c /usr/local (you will probably need \c root athos@1514: privileges to be able to install to that directory). If you want to install it athos@1514: to some other place, then pass the \c --prefix=DIR flag to \c ./configure. In athos@1514: what follows we will assume that you were able to install to directory \c athos@1514: /usr/local, otherwise some extra care is to be taken to use the library. athos@1511: athos@1514: We briefly explain these commands below. athos@1514: athos@1514: \code athos@1514: tar xvzf lemon-0.3.1.tar.gz athos@1514: \endcode athos@1514: This command untars the tar.gz file into a directory named lemon-0.3.1. athos@1514: athos@1514: \code athos@1514: cd lemon-0.3.1 athos@1514: \endcode athos@1514: Enters the directory. athos@1514: athos@1514: \code athos@1514: ./configure athos@1514: \endcode athos@1514: Does some configuration (creates makefiles etc). athos@1514: athos@1514: \code athos@1514: make athos@1514: \endcode athos@1514: This command compiles the .cc files of the library package (the athos@1514: implementation of non-template functions and classes and some test and demo athos@1514: programs) and creates the very important libemon.la file. When athos@1514: linking your program that uses LEMON it needs to access this file. athos@1514: athos@1514: \code athos@1514: make check (This is optional, but recomended. It runs a bunch of tests.) athos@1514: \endcode athos@1514: This is an optional step: it runs the test programs that we developed for athos@1514: LEMON to check athos@1514: whether the library works properly on your platform. athos@1514: athos@1514: \code athos@1514: make install athos@1514: \endcode athos@1514: This will copy the directory structure to its final destination (e.g. to \c athos@1514: /usr/local) so that your system can access it. athos@1175: athos@1173: \section helloworld My first program using LEMON athos@1173: athos@1514: If you have installed LEMON on your system you athos@1514: can paste the following code athos@1175: segment into a file to have a first working program that uses library LEMON. athos@1173: athos@1175: \code athos@1175: #include athos@1175: #include athos@1173: athos@1175: using namespace lemon; athos@1175: athos@1175: int main() athos@1175: { athos@1175: typedef ListGraph Graph; athos@1175: typedef Graph::EdgeIt EdgeIt; athos@1175: typedef Graph::NodeIt NodeIt; athos@1175: athos@1175: Graph g; athos@1175: athos@1175: for (int i = 0; i < 3; i++) athos@1175: g.addNode(); athos@1175: athos@1175: for (NodeIt i(g); i!=INVALID; ++i) athos@1175: for (NodeIt j(g); j!=INVALID; ++j) athos@1175: if (i != j) g.addEdge(i, j); athos@1175: athos@1175: std::cout << "Nodes:"; athos@1175: for (NodeIt i(g); i!=INVALID; ++i) athos@1175: std::cout << " " << g.id(i); athos@1175: std::cout << std::endl; athos@1175: athos@1175: std::cout << "Edges:"; athos@1175: for (EdgeIt i(g); i!=INVALID; ++i) athos@1175: std::cout << " (" << g.id(g.source(i)) << "," << g.id(g.target(i)) << ")"; athos@1175: std::cout << std::endl; athos@1175: athos@1175: \endcode athos@1175: athos@1514: First let us briefly explain how this program works. athos@1175: athos@1175: ListGraph is one of LEMON's graph classes. It is based on linked lists, athos@1175: therefore iterating throuh its edges and nodes is fast. athos@1175: athos@1175: After some convenient typedefs we create a graph and add three nodes to it. athos@1175: Then we add edges to it to form a complete graph. athos@1175: athos@1175: Then we iterate through all nodes of the graph. We use a constructor of the athos@1175: node iterator to initialize it to the first node. The operator++ is used to athos@1175: step to the next node. Using operator++ on the iterator pointing to the last athos@1175: node invalidates the iterator i.e. sets its value to athos@1175: \ref lemon::INVALID "INVALID". This is what we exploit in the stop condition. athos@1175: athos@1175: We can also iterate through all edges of the graph very similarly. The athos@1175: \c target and athos@1175: \c source member functions can be used to access the endpoints of an edge. athos@1175: athos@1514: 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 athos@1514: successful then it is very easy to compile this program with the following athos@1514: command (the argument -lemon tells the compiler that we are using the athos@1514: installed library LEMON): athos@1514: \code athos@1514: g++ hemon.cc -o hemon -lemon athos@1514: \endcode athos@1514: athos@1514: As a result you will get the exacutable \c hemon in athos@1514: this directory that you can run by the command athos@1514: \code athos@1514: ./hemon athos@1514: \endcode athos@1514: athos@1514: athos@1514: If everything has gone well then the previous code fragment prints out the following: athos@1175: athos@1175: \code athos@1175: Nodes: 2 1 0 athos@1175: athos@1175: Edges: (0,2) (1,2) (0,1) (2,1) (1,0) (2,0) athos@1175: \endcode athos@1175: athos@1514: Congratulations! athos@1175: athos@1175: If you want to see more features, go to the \ref quicktour "Quick Tour to athos@1175: LEMON", if you want to see see some demo programs then go to our athos@1175: \ref demoprograms "Demo Programs" page! athos@1175: athos@1175: athos@1175: */