Include functional because of std::less.
3 * This file is a part of LEMON, a generic C++ optimization library
5 * Copyright (C) 2003-2007
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 * (Egervary Research Group on Combinatorial Optimization, EGRES).
9 * Permission to use, modify and distribute this software is granted
10 * provided that this copyright notice appears in all copies. For
11 * precise terms see the accompanying LICENSE file.
13 * This software is provided "AS IS" with no warranty of any kind,
14 * express or implied, and with no claim as to its suitability for any
21 ///\brief LEMON style "Hello World!" program
23 /// This program is intended to be a "Hello World!" program that shows
24 /// the very basic notions of the LEMON library: \ref graphs "graphs" and
25 /// \ref maps-page "maps". Click on the links to read more about these.
27 /// \include hello_world.cc
30 #include <lemon/list_graph.h>
32 using namespace lemon;
34 typedef ListGraph::Node Node;
35 typedef ListGraph::Edge Edge;
40 // Declare the graph itself and a NodeMap, witch will store the characters
41 // assigned to the nodes
43 ListGraph::NodeMap<char> char_map(graph);
46 Node new_node = graph.addNode();
47 char_map[new_node] = 'H';
49 // Store the start node
50 Node start_node = new_node;
52 Node from_node = new_node;
53 new_node = graph.addNode();
54 char_map[new_node] = 'e';
56 // Here we add the first edge...
57 graph.addEdge( from_node, new_node );
59 // ... and we add some more nodes and edges to the graph
61 new_node = graph.addNode();
62 char_map[new_node] = 'l';
63 graph.addEdge( from_node, new_node );
66 new_node = graph.addNode();
67 char_map[new_node] = 'l';
68 graph.addEdge( from_node, new_node );
71 new_node = graph.addNode();
72 char_map[new_node] = 'o';
73 graph.addEdge( from_node, new_node );
76 new_node = graph.addNode();
77 char_map[new_node] = ' ';
78 graph.addEdge( from_node, new_node );
81 new_node = graph.addNode();
82 char_map[new_node] = 'W';
83 graph.addEdge( from_node, new_node );
86 new_node = graph.addNode();
87 char_map[new_node] = 'o';
88 graph.addEdge( from_node, new_node );
91 new_node = graph.addNode();
92 char_map[new_node] = 'r';
93 graph.addEdge( from_node, new_node );
96 new_node = graph.addNode();
97 char_map[new_node] = 'l';
98 graph.addEdge( from_node, new_node );
100 from_node = new_node;
101 new_node = graph.addNode();
102 char_map[new_node] = 'd';
103 graph.addEdge( from_node, new_node );
105 from_node = new_node;
106 new_node = graph.addNode();
107 char_map[new_node] = '\n';
108 graph.addEdge( from_node, new_node );
112 Node current_node = start_node;
113 while( current_node != INVALID )
115 std::cout << char_map[current_node] << std::flush;
117 ListGraph::OutEdgeIt edge(graph, current_node);
118 if( edge != INVALID )
119 current_node = graph.target( edge );
121 current_node = INVALID;