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@1115: reader.addNodeMap("id", id); deba@1037: deba@1032: SmartGraph::NodeMap cost(graph); deba@1115: reader.addNodeMap("cost", cost); deba@1037: deba@1032: SmartGraph::NodeMap color(graph); deba@1115: reader.addNodeMap("color", color); deba@1037: deba@1036: SmartGraph::NodeMap description(graph); deba@1115: reader.addNodeMap("description", description); deba@1037: deba@1036: SmartGraph::EdgeMap mmap(graph); deba@1115: reader.addEdgeMap("mmap", mmap); deba@1037: deba@1036: reader.skipEdgeMap("description"); deba@1037: deba@1037: SmartGraph::Node source; deba@1115: reader.addNode("source", source); deba@1037: deba@1037: SmartGraph::Edge newedge; deba@1115: reader.addEdge("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@1115: 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@1115: cout << mmap[it] << ' ' << id[graph.source(it)] << ' ' << deba@1115: id[graph.target(it)] << endl; deba@1032: } deba@1037: deba@1115: cout << id[source] << ' ' << cost[source] << ' ' << deba@1115: color[source] << ' ' << description[source] << endl; deba@1115: cout << mmap[newedge] << ' ' << id[graph.source(newedge)] << deba@1115: ' ' << id[graph.target(newedge)] << endl; deba@1037: deba@1037: ofstream output("copy.lgf"); deba@1037: GraphWriter writer(output, graph); deba@1037: deba@1115: DescriptorMap > deba@1115: node_ids(graph); deba@1037: deba@1115: writer.addNodeMap("id", node_ids); deba@1115: writer.addNodeMap("format", description); deba@1037: deba@1115: IdMap edge_ids(graph); deba@1037: deba@1115: writer.addEdgeMap("id", edge_ids); deba@1115: writer.addEdgeMap("chars", mmap); deba@1037: deba@1115: writer.addNode("source", node_ids.inverse()[3]); deba@1115: // writer.addEdge("elek", edge_ids.inverse()[6]); deba@1037: writer.write(); deba@1037: deba@1032: return 0; deba@1032: }