deba@1032: #include deba@1037: deba@1037: #include "map_utils.h" deba@1037: deba@1037: deba@1036: #include "graph_reader.h" deba@1037: #include "graph_writer.h" deba@1032: deba@1032: #include deba@1032: #include deba@1032: deba@1032: using namespace std; deba@1032: using namespace lemon; deba@1032: deba@1032: int main() { deba@1032: ifstream input("test.lgf"); deba@1032: SmartGraph graph; deba@1032: GraphReader reader(input, graph); deba@1037: deba@1036: SmartGraph::NodeMap id(graph); deba@1036: reader.readNodeMap("id", id); deba@1037: deba@1032: SmartGraph::NodeMap cost(graph); deba@1032: reader.readNodeMap("cost", cost); deba@1037: deba@1032: SmartGraph::NodeMap color(graph); deba@1032: reader.readNodeMap("color", color); deba@1037: deba@1036: SmartGraph::NodeMap description(graph); deba@1036: reader.readNodeMap("description", description); deba@1037: deba@1036: SmartGraph::EdgeMap mmap(graph); deba@1036: reader.readEdgeMap("mmap", mmap); deba@1037: deba@1036: reader.skipEdgeMap("description"); deba@1037: deba@1037: SmartGraph::Node source; deba@1037: reader.readNode("source", source); deba@1037: deba@1037: SmartGraph::Edge newedge; deba@1037: reader.readEdge("newedge", newedge); deba@1037: deba@1036: try { deba@1036: reader.read(); deba@1036: } catch (IOException& e) { deba@1036: cerr << e.what() << endl; deba@1036: } catch (Exception e) { deba@1036: cerr << e.what() << endl; deba@1036: } deba@1032: for (SmartGraph::NodeIt it(graph); it != INVALID; ++it) { deba@1036: cout << cost[it] << ' ' << color[it] << ' ' << description[it] << endl; deba@1036: } deba@1036: deba@1036: for (SmartGraph::EdgeIt it(graph); it != INVALID; ++it) { deba@1036: cout << mmap[it] << ' ' << id[graph.source(it)] << ' ' << id[graph.target(it)] << endl; deba@1032: } deba@1037: deba@1037: cout << id[source] << ' ' << cost[source] << ' ' << color[source] << ' ' << description[source] << endl; deba@1037: cout << mmap[newedge] << ' ' << id[graph.source(newedge)] << ' ' << id[graph.target(newedge)] << endl; deba@1037: deba@1037: ofstream output("copy.lgf"); deba@1037: GraphWriter writer(output, graph); deba@1037: deba@1037: DescriptorMap > node_ids(graph); deba@1037: deba@1037: writer.writeNodeMap("id", node_ids); deba@1037: writer.writeNodeMap("format", description); deba@1037: deba@1037: DescriptorMap > edge_ids(graph); deba@1037: deba@1037: writer.writeEdgeMap("id", edge_ids); deba@1037: writer.writeEdgeMap("chars", mmap); deba@1037: deba@1037: writer.writeNode("source", node_ids.inverse()[3]); deba@1037: writer.writeEdge("elek", edge_ids.inverse()[6]); deba@1037: writer.write(); deba@1037: deba@1032: return 0; deba@1032: }