# HG changeset patch # User klao # Date 1119905069 0 # Node ID c2c76e4598f6472f0437285b25b8730727e0c177 # Parent 17e367a93cbb0ed4a3fed2885c08b966fb203a33 getstart: hello_lemon.cc moved to a separate file in demo/ diff -r 17e367a93cbb -r c2c76e4598f6 demo/Makefile.am --- a/demo/Makefile.am Mon Jun 27 19:47:09 2005 +0000 +++ b/demo/Makefile.am Mon Jun 27 20:44:29 2005 +0000 @@ -8,6 +8,7 @@ dim_to_lgf \ graph_to_eps_demo \ min_route \ + hello_lemon \ sub_graph_adaptor_demo \ coloring @@ -30,6 +31,8 @@ min_route_SOURCES = min_route.cc +hello_lemon_SOURCES = hello_lemon.cc + sub_graph_adaptor_demo_SOURCES = \ sub_graph_adaptor_demo.cc \ tight_edge_filter_map.h diff -r 17e367a93cbb -r c2c76e4598f6 demo/hello_lemon.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/demo/hello_lemon.cc Mon Jun 27 20:44:29 2005 +0000 @@ -0,0 +1,29 @@ +#include +#include + +int main() +{ + typedef lemon::ListGraph Graph; + typedef Graph::EdgeIt EdgeIt; + typedef Graph::NodeIt NodeIt; + using lemon::INVALID; + + 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); + + std::cout << "Nodes:"; + for (NodeIt i(g); i!=INVALID; ++i) + std::cout << " " << g.id(i); + std::cout << std::endl; + + std::cout << "Edges:"; + for (EdgeIt i(g); i!=INVALID; ++i) + std::cout << " (" << g.id(g.source(i)) << "," << g.id(g.target(i)) << ")"; + std::cout << std::endl; +} diff -r 17e367a93cbb -r c2c76e4598f6 doc/getstart.dox --- a/doc/getstart.dox Mon Jun 27 19:47:09 2005 +0000 +++ b/doc/getstart.dox Mon Jun 27 20:44:29 2005 +0000 @@ -106,40 +106,11 @@ \section helloworld My first program using LEMON If you have installed LEMON on your system you can paste the -following code segment into a file (named e.g. \c hello_lemon.cc) -to have a first working program that uses library LEMON. +following code segment into a file (you can find it as \c +demo/hello_lemon.cc in the LEMON package) to have a first working +program that uses library LEMON. -\code -#include -#include - -int main() -{ - typedef lemon::ListGraph Graph; - typedef Graph::EdgeIt EdgeIt; - typedef Graph::NodeIt NodeIt; - using lemon::INVALID; - - 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); - - std::cout << "Nodes:"; - for (NodeIt i(g); i!=INVALID; ++i) - std::cout << " " << g.id(i); - std::cout << std::endl; - - std::cout << "Edges:"; - for (EdgeIt i(g); i!=INVALID; ++i) - std::cout << " (" << g.id(g.source(i)) << "," << g.id(g.target(i)) << ")"; - std::cout << std::endl; -} -\endcode +\include hello_lemon.cc First let us briefly explain how this program works. @@ -159,11 +130,10 @@ \c target and \c source member functions can be used to access the endpoints of an edge. -If you have saved the preceding code into a file named, say, \c -hello_lemon.cc and your installation of LEMON into directory \c -/usr/local was successful 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 library LEMON): +If your installation of LEMON into directory \c /usr/local was +successful 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 library LEMON): \verbatim g++ hello_lemon.cc -o hello_lemon -lemon