3 * This file is a part of LEMON, a generic C++ optimization library
5 * Copyright (C) 2003-2008
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 * (Egervary Research Group on Combinatorial Optimization, EGRES).
9 * Permission to use, modify and distribute this software is granted
10 * provided that this copyright notice appears in all copies. For
11 * precise terms see the accompanying LICENSE file.
13 * This software is provided "AS IS" with no warranty of any kind,
14 * express or implied, and with no claim as to its suitability for any
21 ///\brief Demonstrating graph input and output
23 /// This program gives an example of how to load a directed graph from
24 /// an \ref lgf-format "LGF" file with the \ref lemon::DigraphReader
25 /// "DigraphReader" class.
27 /// The \c "digraph.lgf" file:
28 /// \include digraph.lgf
30 /// And the program which reads it:
31 /// \include lgf_demo.cc
34 #include <lemon/smart_graph.h>
35 #include <lemon/lgf_reader.h>
36 #include <lemon/lgf_writer.h>
38 using namespace lemon;
42 SmartDigraph::ArcMap<int> cap(g);
43 SmartDigraph::Node s, t;
45 digraphReader("digraph.lgf", g). // read the directed graph into g
46 arcMap("capacity", cap). // read the 'capacity' arc map into cap
47 node("source", s). // read 'source' node to s
48 node("target", t). // read 'target' node to t
51 std::cout << "A digraph is read from 'digraph.lgf'." << std::endl;
52 std::cout << "Number of nodes: " << countNodes(g) << std::endl;
53 std::cout << "Number of arcs: " << countArcs(g) << std::endl;
55 std::cout << "We can write it to the standard output:" << std::endl;
57 digraphWriter(std::cout, g). // write g to the standard output
58 arcMap("capacity", cap). // write cap into 'capacity'
59 node("source", s). // write s to 'source'
60 node("target", t). // write t to 'target'