src/work/deba/graph_io_test.cc
changeset 1365 c280de819a73
parent 1364 ee5959aa4410
child 1366 d00b85f8be45
     1.1 --- a/src/work/deba/graph_io_test.cc	Sun Apr 17 18:57:22 2005 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,83 +0,0 @@
     1.4 -#include <lemon/smart_graph.h>
     1.5 -
     1.6 -#include <lemon/map_utils.h>
     1.7 -
     1.8 -#include <lemon/graph_reader.h>
     1.9 -#include <lemon/graph_writer.h>
    1.10 -
    1.11 -#include <iostream>
    1.12 -#include <fstream>
    1.13 -
    1.14 -using namespace std;
    1.15 -using namespace lemon;
    1.16 -
    1.17 -int main() {
    1.18 -  ifstream input("test.lgf");
    1.19 -  SmartGraph graph;
    1.20 -  GraphReader<SmartGraph> reader(input, graph);
    1.21 -
    1.22 -  SmartGraph::NodeMap<int> id(graph);
    1.23 -  reader.addNodeMap("id", id);
    1.24 -
    1.25 -  SmartGraph::NodeMap<int> cost(graph);
    1.26 -  reader.addNodeMap("cost", cost);
    1.27 - 
    1.28 -  SmartGraph::NodeMap<string> color(graph);
    1.29 -  reader.addNodeMap("color", color);
    1.30 -
    1.31 -  SmartGraph::NodeMap<string> description(graph);
    1.32 -  reader.addNodeMap<QuotedStringReader>("description", description);
    1.33 -
    1.34 -  SmartGraph::EdgeMap<char> mmap(graph);
    1.35 -  reader.addEdgeMap("mmap", mmap);
    1.36 -
    1.37 -  reader.skipEdgeMap<QuotedStringReader>("description");
    1.38 -
    1.39 -  SmartGraph::Node source;
    1.40 -  reader.addNode("source", source);
    1.41 -  
    1.42 -  SmartGraph::Edge newedge;
    1.43 -  reader.addEdge("newedge", newedge);
    1.44 -
    1.45 -  try {
    1.46 -    reader.run();
    1.47 -  } catch (IOError& e) {
    1.48 -    cerr << e.what() << endl;
    1.49 -  } catch (Exception e) {
    1.50 -    cerr << e.what() << endl;
    1.51 -  }
    1.52 -
    1.53 -  for (SmartGraph::NodeIt it(graph); it != INVALID; ++it) {
    1.54 -    cout << cost[it] << ' ' << color[it] << ' ' << description[it] << endl;
    1.55 -  }
    1.56 -
    1.57 -  for (SmartGraph::EdgeIt it(graph); it != INVALID; ++it) {
    1.58 -    cout << mmap[it] << ' ' << id[graph.source(it)] << ' ' << 
    1.59 -      id[graph.target(it)]  << endl;
    1.60 -  }
    1.61 -
    1.62 -  cout << id[source] << ' ' << cost[source] << ' ' <<
    1.63 -    color[source] << ' ' << description[source] << endl;
    1.64 -  cout << mmap[newedge] << ' ' << id[graph.source(newedge)] << 
    1.65 -    ' ' << id[graph.target(newedge)]  << endl;
    1.66 -
    1.67 -  ofstream output("copy.lgf");
    1.68 -  GraphWriter<SmartGraph> writer(output, graph);
    1.69 -  
    1.70 -  DescriptorMap<SmartGraph, SmartGraph::Node, SmartGraph::NodeMap<int> > 
    1.71 -    node_ids(graph);
    1.72 -  
    1.73 -  writer.addNodeMap("id", node_ids);
    1.74 -  writer.addNodeMap<QuotedStringWriter>("format", description);
    1.75 -
    1.76 -  IdMap<SmartGraph, SmartGraph::Edge > edge_ids(graph);
    1.77 -
    1.78 -  writer.addEdgeMap("id", edge_ids);
    1.79 -  writer.addEdgeMap("chars", mmap);
    1.80 -  
    1.81 -  writer.addNode("source", node_ids.inverse()[3]);
    1.82 -  //  writer.addEdge("elek", edge_ids.inverse()[6]);
    1.83 -  writer.run();
    1.84 -  
    1.85 -  return 0;
    1.86 -}