deba@127: /* -*- C++ -*-
deba@127:  *
deba@127:  * This file is a part of LEMON, a generic C++ optimization library
deba@127:  *
deba@127:  * Copyright (C) 2003-2008
deba@127:  * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
deba@127:  * (Egervary Research Group on Combinatorial Optimization, EGRES).
deba@127:  *
deba@127:  * Permission to use, modify and distribute this software is granted
deba@127:  * provided that this copyright notice appears in all copies. For
deba@127:  * precise terms see the accompanying LICENSE file.
deba@127:  *
deba@127:  * This software is provided "AS IS" with no warranty of any kind,
deba@127:  * express or implied, and with no claim as to its suitability for any
deba@127:  * purpose.
deba@127:  *
deba@127:  */
deba@127: 
deba@127: ///\ingroup demos
deba@127: ///\file
deba@127: ///\brief Demonstrating graph input and output
deba@127: ///
deba@164: /// This program gives an example of how to load a directed graph from
deba@164: /// an \ref lgf-format "LGF" file with the \ref lemon::DigraphReader
deba@164: /// "DigraphReader" class.
deba@127: ///
deba@164: /// The \c "digraph.lgf" file:
deba@164: /// \include digraph.lgf
deba@164: ///
deba@164: /// And the program which reads it:
deba@164: /// \include lgf_demo.cc
deba@127: 
deba@127: #include <iostream>
deba@127: #include <lemon/smart_graph.h>
deba@127: #include <lemon/lgf_reader.h>
deba@127: #include <lemon/lgf_writer.h>
deba@127: #include <lemon/random.h>
deba@127: 
deba@127: 
deba@127: using namespace lemon;
deba@127: 
deba@164: int main() {
deba@164:   SmartDigraph g;
deba@164:   SmartDigraph::ArcMap<int> cap(g);
deba@164:   SmartDigraph::Node s, t;
deba@127: 
deba@164:   digraphReader("digraph.lgf", g). // read the directeg graph into g
deba@164:     arcMap("capacity", cap).       // read the 'capacity' arc map into cap
deba@164:     node("source", s).             // read 'source' node to s
deba@164:     node("target", t).             // read 'target' node to t
deba@164:     run();
deba@127: 
deba@164:   std::cout << "Digraph read from 'digraph.lgf'" << std::endl;
deba@164:   std::cout << "Number of nodes: " << countNodes(g) << std::endl;
deba@164:   std::cout << "Number of arcs: " << countArcs(g) << std::endl;
deba@127: 
deba@164:   std::cout << "We can write it to the standard output:" << std::endl;
deba@127: 
deba@164:   digraphWriter(std::cout, g).     // write g to the standard output
deba@164:     arcMap("capacity", cap).       // write cap into 'capacity'
deba@164:     node("source", s).             // write s to 'source'
deba@164:     node("target", t).             // write t to 'target'
deba@164:     run();
deba@127: 
deba@127:   return 0;
deba@127: }