/**
\page quicktour Quick Tour to LEMON
Let us first answer the question **"What do I want to use LEMON for?"
**.
LEMON is a C++ library, so you can use it if you want to write C++
programs. What kind of tasks does the library LEMON help to solve?
It helps to write programs that solve optimization problems that arise
frequently when **designing and testing certain networks**, for example
in telecommunication, computer networks, and other areas that I cannot
think of now. A very natural way of modelling these networks is by means
of a ** graph** (we will always mean a directed graph by that and say
** undirected graph ** otherwise).
So if you want to write a program that works with
graphs then you might find it useful to use our library LEMON. LEMON
defines various graph concepts depending on what you want to do with the
graph: a very good description can be found in the page
about \ref graphs "graphs".
You will also want to assign data to the edges or nodes of the graph, for example a length or capacity function defined on the edges. You can do this in LEMON using so called \ref maps "maps". You can define a map on the nodes or on the edges of the graph and the value of the map (the range of the function) can be practically almost any type. Read more about maps \ref maps-page "here".
Some examples are the following (you will find links next to the code fragments that help to download full demo programs):
- First we give two examples that show how to instantiate a graph. The
first one shows the methods that add nodes and edges, but one will
usually use the second way which reads a graph from a stream (file).
-# The following code fragment shows how to fill a graph with data. It creates a complete graph on 4 nodes. The type Listgraph is one of the LEMON graph types: the typedefs in the beginning are for convenience and we will supppose them later as well.
\code
typedef ListGraph Graph;
typedef Graph::Edge Edge;
typedef Graph::InEdgeIt InEdgeIt;
typedef Graph::OutEdgeIt OutEdgeIt;
typedef Graph::EdgeIt EdgeIt;
typedef Graph::Node Node;
typedef Graph::NodeIt NodeIt;
Graph g;
for (int i = 0; i < 3; i++)
g.addNode();
for (NodeIt i(g); i!=INVALID; ++i)
for (NodeIt j(g); j!=INVALID; ++j)
if (i != j) g.addEdge(i, j);
\endcode
If you want to read more on the LEMON graph structures and concepts, read the page about \ref graphs "graphs".
-# The following code shows how to read a graph from a stream (e.g. a file). LEMON supports the DIMACS file format: it can read a graph instance from a file
in that format (find the documentation of the DIMECS file format on the web).
\code
Graph g;
std::ifstream f("graph.dim");
readDimacs(f, g);
\endcode
One can also store network (graph+capacity on the edges) instances and other things in DIMACS format and use these in LEMON: to see the details read the documentation of the \ref dimacs.h "Dimacs file format reader".
- If you want to solve some transportation problems in a network then
you will want to find shortest paths between nodes of a graph. This is
usually solved using Dijkstra's algorithm. A utility
that solves this is the \ref lemon::Dijkstra "LEMON Dijkstra class".
The following code is a simple program using the \ref lemon::Dijkstra "LEMON
Dijkstra class" and it also shows how to define a map on the edges (the length
function):
\code
typedef ListGraph Graph;
typedef Graph::Node Node;
typedef Graph::Edge Edge;
typedef Graph::EdgeMap LengthMap;
Graph g;
//An example from Ahuja's book
Node s=g.addNode();
Node v2=g.addNode();
Node v3=g.addNode();
Node v4=g.addNode();
Node v5=g.addNode();
Node t=g.addNode();
Edge s_v2=g.addEdge(s, v2);
Edge s_v3=g.addEdge(s, v3);
Edge v2_v4=g.addEdge(v2, v4);
Edge v2_v5=g.addEdge(v2, v5);
Edge v3_v5=g.addEdge(v3, v5);
Edge v4_t=g.addEdge(v4, t);
Edge v5_t=g.addEdge(v5, t);
LengthMap len(g);
len.set(s_v2, 10);
len.set(s_v3, 10);
len.set(v2_v4, 5);
len.set(v2_v5, 8);
len.set(v3_v5, 5);
len.set(v4_t, 8);
len.set(v5_t, 8);
std::cout << "The id of s is " << g.id(s)<< ", the id of t is " << g.id(t)<<"."< dijkstra_test(g,len);
dijkstra_test.run(s);
std::cout << "The distance of node t from node s: " << dijkstra_test.dist(t)<minimum spanning tree in
an undirected graph. This can be found using the Kruskal algorithm: the
class \ref lemon::Kruskal "LEMON Kruskal class" does this job for you.
The following code fragment shows an example:
\code
\endcode
*/