hello_lemon.cc to have a first working program that uses LEMON.
#include <iostream> #include <lemon/list_graph.h> int main() { typedef lemon::ListDigraph Graph; Graph g; Graph::Node u = g.addNode(); Graph::Node v = g.addNode(); Graph::Arc e = g.addArc(u, v); std::cout << "Hello World! This is LEMON library here." << std::endl; std::cout << "We have a directed graph with " << countNodes(g) << " nodes and " << countArcs(g) << " arc." << std::endl; return 0; }
In this small example a directed graph is created with two nodes and an arc added to it.
Now let us compile this code. (We suppose that you have it in a file called hello_lemon.cc.)
If LEMON is installed system-wide (into directory /usr/local), then it is very easy to compile this program with the following command (the argument -lemon tells the compiler that we are using the installed LEMON).
g++ -lemon -o hello_lemon hello_lemon.cc
As a result you will get the exacutable hello_lemon in the current directory, which you can run by the following command.
./hello_lemon
If LEMON is installed user-local into a directory (e.g. ~/lemon), then compiling the code is a bit more difficult. You have to issue a command like this.
g++ -lemon -I ~/lemon/include -L ~/lemon/lib -o hello_lemon hello_lemon.cc
If everything has gone well, then our program prints out the followings.
Hello World! This is LEMON library here. We have a directed graph with 2 nodes and 1 arc.
If you managed to compile and run this example code without any problems, you may go on reading this tutorial to get to know the basic notions, features and tools of LEMON. However if you encountered problems that you did not manage to solve, do not hesitate to contact us.
<< 1 Introduction | Home | 3 Basic Concepts >>
1.5.8