src/work/deba/graph_io_test.cc
changeset 1036 2f514b5c7122
parent 1032 9e903d3a1ef6
child 1037 3eaff8d04171
     1.1 --- a/src/work/deba/graph_io_test.cc	Thu Dec 09 17:02:53 2004 +0000
     1.2 +++ b/src/work/deba/graph_io_test.cc	Tue Dec 14 19:26:50 2004 +0000
     1.3 @@ -1,5 +1,5 @@
     1.4  #include <lemon/smart_graph.h>
     1.5 -#include <lemon/graph_reader.h>
     1.6 +#include "graph_reader.h"
     1.7  
     1.8  #include <iostream>
     1.9  #include <fstream>
    1.10 @@ -11,13 +11,30 @@
    1.11    ifstream input("test.lgf");
    1.12    SmartGraph graph;
    1.13    GraphReader<SmartGraph> reader(input, graph);
    1.14 +  SmartGraph::NodeMap<int> id(graph);
    1.15 +  reader.readNodeMap("id", id);
    1.16    SmartGraph::NodeMap<int> cost(graph);
    1.17    reader.readNodeMap("cost", cost);
    1.18    SmartGraph::NodeMap<string> color(graph);
    1.19    reader.readNodeMap("color", color);
    1.20 -  reader.read();
    1.21 +  SmartGraph::NodeMap<string> description(graph);
    1.22 +  reader.readNodeMap<QuotedStringReader>("description", description);
    1.23 +  SmartGraph::EdgeMap<char> mmap(graph);
    1.24 +  reader.readEdgeMap("mmap", mmap);
    1.25 +  reader.skipEdgeMap<QuotedStringReader>("description");
    1.26 +  try {
    1.27 +    reader.read();
    1.28 +  } catch (IOException& e) {
    1.29 +    cerr << e.what() << endl;
    1.30 +  } catch (Exception e) {
    1.31 +    cerr << e.what() << endl;
    1.32 +  }
    1.33    for (SmartGraph::NodeIt it(graph); it != INVALID; ++it) {
    1.34 -    cout << cost[it] << color[it] << endl;
    1.35 +    cout << cost[it] << ' ' << color[it] << ' ' << description[it] << endl;
    1.36 +  }
    1.37 +
    1.38 +  for (SmartGraph::EdgeIt it(graph); it != INVALID; ++it) {
    1.39 +    cout << mmap[it] << ' ' << id[graph.source(it)] << ' ' << id[graph.target(it)]  << endl;
    1.40    }
    1.41    return 0;
    1.42  }