[Lemon-commits] Alpar Juttner: Merge
Lemon HG
hg at lemon.cs.elte.hu
Sun Jul 6 08:49:29 CEST 2008
details: http://lemon.cs.elte.hu/hg/lemon/rev/65cba1032f90
changeset: 193:65cba1032f90
user: Alpar Juttner <alpar [at] cs.elte.hu>
date: Sun Jul 06 07:49:03 2008 +0100
description:
Merge
diffstat:
1 file changed, 16 insertions(+), 10 deletions(-)
demo/lgf_demo.cc | 26 ++++++++++++++++----------
diffs (47 lines):
diff -r 7bf5f97d574f -r 65cba1032f90 demo/lgf_demo.cc
--- a/demo/lgf_demo.cc Sat Jul 05 00:14:27 2008 +0200
+++ b/demo/lgf_demo.cc Sun Jul 06 07:49:03 2008 +0100
@@ -20,14 +20,15 @@
///\file
///\brief Demonstrating graph input and output
///
-/// This program gives an example of how to load a directed graph from
-/// an \ref lgf-format "LGF" file with the \ref lemon::DigraphReader
-/// "DigraphReader" class.
+/// This program gives an example of how to read and write a digraph
+/// and additional maps from/to a stream or a file using the
+/// \ref lgf-format "LGF" format.
///
/// The \c "digraph.lgf" file:
/// \include digraph.lgf
///
-/// And the program which reads it:
+/// And the program which reads it and prints the digraph to the
+/// standard output:
/// \include lgf_demo.cc
#include <iostream>
@@ -41,12 +42,17 @@
SmartDigraph g;
SmartDigraph::ArcMap<int> cap(g);
SmartDigraph::Node s, t;
-
- digraphReader("digraph.lgf", g). // read the directed graph into g
- arcMap("capacity", cap). // read the 'capacity' arc map into cap
- node("source", s). // read 'source' node to s
- node("target", t). // read 'target' node to t
- run();
+
+ try {
+ digraphReader("digraph.lgf", g). // read the directed graph into g
+ arcMap("capacity", cap). // read the 'capacity' arc map into cap
+ node("source", s). // read 'source' node to s
+ node("target", t). // read 'target' node to t
+ run();
+ } catch (DataFormatError& error) { // check if there was any error
+ std::cerr << "Error: " << error.what() << std::endl;
+ return -1;
+ }
std::cout << "A digraph is read from 'digraph.lgf'." << std::endl;
std::cout << "Number of nodes: " << countNodes(g) << std::endl;
More information about the Lemon-commits
mailing list