1 /** |
1 /** |
2 \page getting_started Getting Started |
2 \page getting_started Getting Started |
3 |
3 |
4 At the beginning we hardly suggest that you open your favorite text editor |
4 At the beginning we strongly suggest that you open your favorite text |
5 and enter the code simultaneously as you read it. Compiling the demos is also |
5 editor and enter the code simultaneously as you read it. Compiling the |
6 a good exercise. |
6 demos is also a good exercise. |
7 |
7 |
8 As the first example we show you a lemon style "Hello World" program. Now we |
8 As the first example we show you a lemon style "Hello World" |
9 explain almost every line, but later we will skip the basics and focus on new |
9 program. Now we explain almost every line, but later we will skip the |
10 things. |
10 basics and focus on new things. |
11 |
11 |
12 \section hello_world Hello World in LEMON |
12 \section hello_world Hello World in LEMON |
13 |
13 |
14 In this little program we give you a taste of the LEMON programming. |
14 In this little program we give you a taste of the LEMON programming. |
15 |
15 |
26 The next few lines are not necessary but useful shortcuts, if you don't |
26 The next few lines are not necessary but useful shortcuts, if you don't |
27 want to type \c lemon::ListGraph::Node every time. |
27 want to type \c lemon::ListGraph::Node every time. |
28 \skip using |
28 \skip using |
29 \until Edge |
29 \until Edge |
30 |
30 |
31 For this demo we need to declare a ListGraph and a special NodeMap to store the |
31 For this demo we need to declare a ListGraph and a special NodeMap to |
32 characters associated to the graph's nodes. |
32 store the characters associated to the graph's nodes. |
33 \skip main |
33 \skip main |
34 \until char_map |
34 \until char_map |
35 |
35 |
36 Adding nodes to the graph is very easy. |
36 Adding nodes to the graph is very easy. |
37 \skip new_node |
37 \skip new_node |
38 \until addNode |
38 \until addNode |
39 |
39 |
40 When a new node or edge to the graph the assigned maps are automatically resized. |
40 When a new node or edge is added to the graph the assigned maps are automatically resized. |
41 So graphs can be build dynamically. The usage of a map is very natural. |
41 So graphs can be built dynamically. The usage of a map is very natural. |
42 \skip char_map |
42 \skip char_map |
43 \until char_map |
43 \until char_map |
44 |
44 |
45 Notice that no reference or additional assignment needed to work with nodes. |
45 Notice that no reference or additional assignment is needed to work with nodes. |
46 They won't become illegal or won't lead to throwing any exceptions. |
46 They won't become illegal or won't lead to throwing any exceptions. |
47 You can declare and handle node like every other basic type such as \c int. |
47 You can declare and handle a node like every other basic type such as \c int. |
48 \skip Store |
48 \skip Store |
49 \until char_map |
49 \until char_map |
50 |
50 |
51 As one expects adding an Edge is similar. You need to define the \b source node |
51 As one expects adding an Edge is similar. You need to define the \b source node |
52 and the \b destination node. The nodes must belong to the graph of course. The |
52 and the \b destination node. The nodes must belong to the graph of course. The |
53 Edge has the direction from the source to the destination. In some case you don't |
53 Edge has the direction from the source to the destination. In some cases you don't |
54 want the edges to be directed - then you use an undirected graph. For example |
54 want the edges to be directed - then you use an undirected graph. For example |
55 lemon::ListUGraph. |
55 lemon::ListUGraph. |
56 \skip addEdge |
56 \skip addEdge |
57 \until addEdge |
57 \until addEdge |
58 |
58 |