demo/reader_writer_demo.cc
author athos
Thu, 07 Jul 2005 15:00:04 +0000
changeset 1542 0219ee65ffcc
parent 1530 d99c3c84f797
child 1583 2b329fd595ef
permissions -rw-r--r--
Some testing of the LP interface: bugs got fixed.
athos@1528
     1
#include <iostream>
athos@1528
     2
#include <lemon/smart_graph.h>
athos@1528
     3
#include <lemon/invalid.h>
athos@1528
     4
#include <lemon/graph_reader.h>
athos@1528
     5
#include <lemon/graph_writer.h>
athos@1528
     6
athos@1528
     7
athos@1528
     8
using namespace lemon;
athos@1528
     9
athos@1528
    10
int main() {
athos@1528
    11
  SmartGraph graph;
athos@1528
    12
athos@1528
    13
  try {
athos@1528
    14
    std::string filename="sample.lgf";
athos@1528
    15
    GraphReader<SmartGraph> reader(filename,graph);
athos@1528
    16
    SmartGraph::EdgeMap<int> cap(graph);
athos@1528
    17
    reader.readEdgeMap("capacity",cap);
athos@1528
    18
    reader.run();
athos@1528
    19
athos@1528
    20
    std::cout << "Hello! We have read a graph from file " << filename<< 
athos@1528
    21
      " and some maps on it: now we write this to the standard output!" << 
athos@1528
    22
      std::endl;
athos@1528
    23
athos@1528
    24
athos@1528
    25
    GraphWriter<SmartGraph> writer(std::cout, graph);
athos@1528
    26
    writer.writeEdgeMap("multiplicity", cap);
athos@1528
    27
    writer.run();
athos@1528
    28
     
athos@1528
    29
  } catch (DataFormatError& error) {
athos@1528
    30
    std::cerr << error.what() << std::endl;
athos@1528
    31
  }
athos@1528
    32
athos@1528
    33
athos@1528
    34
  return 0;
athos@1528
    35
}