#include #include #include #include #include #include using namespace std; using namespace lemon; int main() { ifstream input("test.lgf"); SmartGraph graph; GraphReader reader(input, graph); SmartGraph::NodeMap id(graph); reader.addNodeMap("id", id); SmartGraph::NodeMap cost(graph); reader.addNodeMap("cost", cost); SmartGraph::NodeMap color(graph); reader.addNodeMap("color", color); SmartGraph::NodeMap description(graph); reader.addNodeMap("description", description); SmartGraph::EdgeMap mmap(graph); reader.addEdgeMap("mmap", mmap); reader.skipEdgeMap("description"); SmartGraph::Node source; reader.addNode("source", source); SmartGraph::Edge newedge; reader.addEdge("newedge", newedge); try { reader.run(); } catch (IOError& e) { cerr << e.what() << endl; } catch (Exception e) { cerr << e.what() << endl; } for (SmartGraph::NodeIt it(graph); it != INVALID; ++it) { cout << cost[it] << ' ' << color[it] << ' ' << description[it] << endl; } for (SmartGraph::EdgeIt it(graph); it != INVALID; ++it) { cout << mmap[it] << ' ' << id[graph.source(it)] << ' ' << id[graph.target(it)] << endl; } cout << id[source] << ' ' << cost[source] << ' ' << color[source] << ' ' << description[source] << endl; cout << mmap[newedge] << ' ' << id[graph.source(newedge)] << ' ' << id[graph.target(newedge)] << endl; ofstream output("copy.lgf"); GraphWriter writer(output, graph); DescriptorMap > node_ids(graph); writer.addNodeMap("id", node_ids); writer.addNodeMap("format", description); IdMap edge_ids(graph); writer.addEdgeMap("id", edge_ids); writer.addEdgeMap("chars", mmap); writer.addNode("source", node_ids.inverse()[3]); // writer.addEdge("elek", edge_ids.inverse()[6]); writer.run(); return 0; }