Solve conflict.
1 #include <lemon/smart_graph.h>
3 #include <lemon/map_utils.h>
5 #include <lemon/graph_reader.h>
6 #include <lemon/graph_writer.h>
12 using namespace lemon;
15 ifstream input("test.lgf");
17 GraphReader<SmartGraph> reader(input, graph);
19 SmartGraph::NodeMap<int> id(graph);
20 reader.addNodeMap("id", id);
22 SmartGraph::NodeMap<int> cost(graph);
23 reader.addNodeMap("cost", cost);
25 SmartGraph::NodeMap<string> color(graph);
26 reader.addNodeMap("color", color);
28 SmartGraph::NodeMap<string> description(graph);
29 reader.addNodeMap<QuotedStringReader>("description", description);
31 SmartGraph::EdgeMap<char> mmap(graph);
32 reader.addEdgeMap("mmap", mmap);
34 reader.skipEdgeMap<QuotedStringReader>("description");
36 SmartGraph::Node source;
37 reader.addNode("source", source);
39 SmartGraph::Edge newedge;
40 reader.addEdge("newedge", newedge);
44 } catch (IOError& e) {
45 cerr << e.what() << endl;
46 } catch (Exception e) {
47 cerr << e.what() << endl;
50 for (SmartGraph::NodeIt it(graph); it != INVALID; ++it) {
51 cout << cost[it] << ' ' << color[it] << ' ' << description[it] << endl;
54 for (SmartGraph::EdgeIt it(graph); it != INVALID; ++it) {
55 cout << mmap[it] << ' ' << id[graph.source(it)] << ' ' <<
56 id[graph.target(it)] << endl;
59 cout << id[source] << ' ' << cost[source] << ' ' <<
60 color[source] << ' ' << description[source] << endl;
61 cout << mmap[newedge] << ' ' << id[graph.source(newedge)] <<
62 ' ' << id[graph.target(newedge)] << endl;
64 ofstream output("copy.lgf");
65 GraphWriter<SmartGraph> writer(output, graph);
67 DescriptorMap<SmartGraph, SmartGraph::Node, SmartGraph::NodeMap<int> >
70 writer.addNodeMap("id", node_ids);
71 writer.addNodeMap<QuotedStringWriter>("format", description);
73 IdMap<SmartGraph, SmartGraph::Edge > edge_ids(graph);
75 writer.addEdgeMap("id", edge_ids);
76 writer.addEdgeMap("chars", mmap);
78 writer.addNode("source", node_ids.inverse()[3]);
79 // writer.addEdge("elek", edge_ids.inverse()[6]);