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