/* -*- C++ -*-
* demo/lp_maxflow_demo.cc - Part of LEMON, a generic C++ optimization library
*
* Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
* (Egervary Research Group on Combinatorial Optimization, EGRES).
*
* Permission to use, modify and distribute this software is granted
* provided that this copyright notice appears in all copies. For
* precise terms see the accompanying LICENSE file.
*
* This software is provided "AS IS" with no warranty of any kind,
* express or implied, and with no claim as to its suitability for any
* purpose.
*
*/
///\ingroup demos
///\file
///\brief Demonstrating graph input and output
///
/// This simple demo program gives an example of how to read and write
/// a graph and additional maps (on the nodes or the edges) from/to a
/// stream.
#include
#include
#include
#include
#include
using namespace lemon;
int main() {
SmartGraph graph;
try {
std::string filename="sample.lgf";
GraphReader reader(filename,graph);
SmartGraph::EdgeMap cap(graph);
reader.readEdgeMap("capacity",cap);
reader.run();
std::cout << "Hello! We have read a graph from file " << filename<<
" and some maps on it:\n now we write it to the standard output!" <<
std::endl;
GraphWriter writer(std::cout, graph);
writer.writeEdgeMap("multiplicity", cap);
writer.run();
} catch (DataFormatError& error) {
std::cerr << error.what() << std::endl;
}
return 0;
}