1.1 --- a/demo/lgf_demo.cc Fri Jul 04 16:12:31 2008 +0200
1.2 +++ b/demo/lgf_demo.cc Sat Jul 05 17:22:28 2008 +0200
1.3 @@ -20,22 +20,21 @@
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 #include <lemon/smart_graph.h>
1.24 #include <lemon/lgf_reader.h>
1.25 #include <lemon/lgf_writer.h>
1.26 -#include <lemon/random.h>
1.27 -
1.28
1.29 using namespace lemon;
1.30
1.31 @@ -43,14 +42,19 @@
1.32 SmartDigraph g;
1.33 SmartDigraph::ArcMap<int> cap(g);
1.34 SmartDigraph::Node s, t;
1.35 +
1.36 + try {
1.37 + digraphReader("digraph.lgf", g). // read the directed graph into g
1.38 + arcMap("capacity", cap). // read the 'capacity' arc map into cap
1.39 + node("source", s). // read 'source' node to s
1.40 + node("target", t). // read 'target' node to t
1.41 + run();
1.42 + } catch (DataFormatError& error) { // check if there was any error
1.43 + std::cerr << "Error: " << error.what() << std::endl;
1.44 + return -1;
1.45 + }
1.46
1.47 - digraphReader("digraph.lgf", g). // read the directeg graph into g
1.48 - arcMap("capacity", cap). // read the 'capacity' arc map into cap
1.49 - node("source", s). // read 'source' node to s
1.50 - node("target", t). // read 'target' node to t
1.51 - run();
1.52 -
1.53 - std::cout << "Digraph read from 'digraph.lgf'" << std::endl;
1.54 + std::cout << "A digraph is read from 'digraph.lgf'." << std::endl;
1.55 std::cout << "Number of nodes: " << countNodes(g) << std::endl;
1.56 std::cout << "Number of arcs: " << countArcs(g) << std::endl;
1.57