1.1 --- a/demo/lgf_demo.cc Sat Jul 05 00:14:27 2008 +0200
1.2 +++ b/demo/lgf_demo.cc Sun Jul 06 07:49:03 2008 +0100
1.3 @@ -20,14 +20,15 @@
1.4 ///\file
1.5 ///\brief Demonstrating graph input and output
1.6 ///
1.7 -/// This program gives an example of how to load a directed graph from
1.8 -/// an \ref lgf-format "LGF" file with the \ref lemon::DigraphReader
1.9 -/// "DigraphReader" class.
1.10 +/// This program gives an example of how to read and write a digraph
1.11 +/// and additional maps from/to a stream or a file using the
1.12 +/// \ref lgf-format "LGF" format.
1.13 ///
1.14 /// The \c "digraph.lgf" file:
1.15 /// \include digraph.lgf
1.16 ///
1.17 -/// And the program which reads it:
1.18 +/// And the program which reads it and prints the digraph to the
1.19 +/// standard output:
1.20 /// \include lgf_demo.cc
1.21
1.22 #include <iostream>
1.23 @@ -41,12 +42,17 @@
1.24 SmartDigraph g;
1.25 SmartDigraph::ArcMap<int> cap(g);
1.26 SmartDigraph::Node s, t;
1.27 -
1.28 - digraphReader("digraph.lgf", g). // read the directed graph into g
1.29 - arcMap("capacity", cap). // read the 'capacity' arc map into cap
1.30 - node("source", s). // read 'source' node to s
1.31 - node("target", t). // read 'target' node to t
1.32 - run();
1.33 +
1.34 + try {
1.35 + digraphReader("digraph.lgf", g). // read the directed graph into g
1.36 + arcMap("capacity", cap). // read the 'capacity' arc map into cap
1.37 + node("source", s). // read 'source' node to s
1.38 + node("target", t). // read 'target' node to t
1.39 + run();
1.40 + } catch (DataFormatError& error) { // check if there was any error
1.41 + std::cerr << "Error: " << error.what() << std::endl;
1.42 + return -1;
1.43 + }
1.44
1.45 std::cout << "A digraph is read from 'digraph.lgf'." << std::endl;
1.46 std::cout << "Number of nodes: " << countNodes(g) << std::endl;