| 1 | #include <lemon/smart_graph.h> |
|---|
| 2 | #include "graph_reader.h" |
|---|
| 3 | |
|---|
| 4 | #include <iostream> |
|---|
| 5 | #include <fstream> |
|---|
| 6 | |
|---|
| 7 | using namespace std; |
|---|
| 8 | using namespace lemon; |
|---|
| 9 | |
|---|
| 10 | int main() { |
|---|
| 11 | ifstream input("test.lgf"); |
|---|
| 12 | SmartGraph graph; |
|---|
| 13 | GraphReader<SmartGraph> reader(input, graph); |
|---|
| 14 | SmartGraph::NodeMap<int> id(graph); |
|---|
| 15 | reader.readNodeMap("id", id); |
|---|
| 16 | SmartGraph::NodeMap<int> cost(graph); |
|---|
| 17 | reader.readNodeMap("cost", cost); |
|---|
| 18 | SmartGraph::NodeMap<string> color(graph); |
|---|
| 19 | reader.readNodeMap("color", color); |
|---|
| 20 | SmartGraph::NodeMap<string> description(graph); |
|---|
| 21 | reader.readNodeMap<QuotedStringReader>("description", description); |
|---|
| 22 | SmartGraph::EdgeMap<char> mmap(graph); |
|---|
| 23 | reader.readEdgeMap("mmap", mmap); |
|---|
| 24 | reader.skipEdgeMap<QuotedStringReader>("description"); |
|---|
| 25 | try { |
|---|
| 26 | reader.read(); |
|---|
| 27 | } catch (IOException& e) { |
|---|
| 28 | cerr << e.what() << endl; |
|---|
| 29 | } catch (Exception e) { |
|---|
| 30 | cerr << e.what() << endl; |
|---|
| 31 | } |
|---|
| 32 | for (SmartGraph::NodeIt it(graph); it != INVALID; ++it) { |
|---|
| 33 | cout << cost[it] << ' ' << color[it] << ' ' << description[it] << endl; |
|---|
| 34 | } |
|---|
| 35 | |
|---|
| 36 | for (SmartGraph::EdgeIt it(graph); it != INVALID; ++it) { |
|---|
| 37 | cout << mmap[it] << ' ' << id[graph.source(it)] << ' ' << id[graph.target(it)] << endl; |
|---|
| 38 | } |
|---|
| 39 | return 0; |
|---|
| 40 | } |
|---|