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