Merge
authorAlpar Juttner <alpar@cs.elte.hu>
Sun, 06 Jul 2008 07:49:03 +0100
changeset 19365cba1032f90
parent 192 7bf5f97d574f
parent 191 abc5b9d0c67e
child 194 74cd0c58b348
child 195 aa45ff44fcf3
child 197 5893bacaa720
Merge
demo/lgf_demo.cc
     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;