author | deba |
Mon, 19 Feb 2007 12:11:41 +0000 | |
changeset 2368 | 6b2e8b734ae7 |
parent 1875 | 98698b69a902 |
child 2391 | 14a343be7a5a |
permissions | -rw-r--r-- |
athos@1583 | 1 |
/* -*- C++ -*- |
athos@1583 | 2 |
* |
alpar@1956 | 3 |
* This file is a part of LEMON, a generic C++ optimization library |
alpar@1956 | 4 |
* |
alpar@1956 | 5 |
* Copyright (C) 2003-2006 |
alpar@1956 | 6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
athos@1583 | 7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES). |
athos@1583 | 8 |
* |
athos@1583 | 9 |
* Permission to use, modify and distribute this software is granted |
athos@1583 | 10 |
* provided that this copyright notice appears in all copies. For |
athos@1583 | 11 |
* precise terms see the accompanying LICENSE file. |
athos@1583 | 12 |
* |
athos@1583 | 13 |
* This software is provided "AS IS" with no warranty of any kind, |
athos@1583 | 14 |
* express or implied, and with no claim as to its suitability for any |
athos@1583 | 15 |
* purpose. |
athos@1583 | 16 |
* |
athos@1583 | 17 |
*/ |
athos@1583 | 18 |
|
athos@1583 | 19 |
///\ingroup demos |
athos@1583 | 20 |
///\file |
athos@1583 | 21 |
///\brief Demonstrating graph input and output |
athos@1583 | 22 |
/// |
athos@1583 | 23 |
/// This simple demo program gives an example of how to read and write |
athos@1583 | 24 |
/// a graph and additional maps (on the nodes or the edges) from/to a |
athos@1583 | 25 |
/// stream. |
alpar@1641 | 26 |
/// |
alpar@1641 | 27 |
/// \include reader_writer_demo.cc |
athos@1583 | 28 |
|
athos@1528 | 29 |
#include <iostream> |
athos@1528 | 30 |
#include <lemon/smart_graph.h> |
athos@1528 | 31 |
#include <lemon/graph_reader.h> |
athos@1528 | 32 |
#include <lemon/graph_writer.h> |
athos@1528 | 33 |
|
athos@1528 | 34 |
|
athos@1528 | 35 |
using namespace lemon; |
athos@1528 | 36 |
|
athos@1528 | 37 |
int main() { |
athos@1528 | 38 |
SmartGraph graph; |
athos@1528 | 39 |
|
athos@1528 | 40 |
try { |
athos@1528 | 41 |
std::string filename="sample.lgf"; |
athos@1528 | 42 |
GraphReader<SmartGraph> reader(filename,graph); |
athos@1528 | 43 |
SmartGraph::EdgeMap<int> cap(graph); |
athos@1528 | 44 |
reader.readEdgeMap("capacity",cap); |
athos@1528 | 45 |
reader.run(); |
athos@1528 | 46 |
|
athos@1528 | 47 |
std::cout << "Hello! We have read a graph from file " << filename<< |
athos@1583 | 48 |
" and some maps on it:\n now we write it to the standard output!" << |
athos@1528 | 49 |
std::endl; |
athos@1528 | 50 |
|
athos@1528 | 51 |
|
athos@1528 | 52 |
GraphWriter<SmartGraph> writer(std::cout, graph); |
athos@1528 | 53 |
writer.writeEdgeMap("multiplicity", cap); |
athos@1528 | 54 |
writer.run(); |
athos@1528 | 55 |
|
athos@1528 | 56 |
} catch (DataFormatError& error) { |
athos@1528 | 57 |
std::cerr << error.what() << std::endl; |
athos@1528 | 58 |
} |
athos@1528 | 59 |
|
athos@1528 | 60 |
|
athos@1528 | 61 |
return 0; |
athos@1528 | 62 |
} |